Skip to content

[Reservation] New Reservation Request #56

[Reservation] New Reservation Request

[Reservation] New Reservation Request #56

Workflow file for this run

name: Process Issue Open/Edit
on:
issues:
types:
- opened
- edited
- reopened
permissions:
contents: read
id-token: write
issues: write
jobs:
validate:
name: Validate Reservation
runs-on: ubuntu-latest
# This job should only be run on issues with the `reservation` label.
if: |
contains(github.event.issue.labels.*.name, 'reservation')
steps:
# This is required to ensure the issue form template and any validation
# scripts are included in the workspace.
- name: Checkout
id: checkout
uses: actions/checkout@v4
# Since this workflow include custom validation scripts, we need to
# install Node.js and any dependencies.
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .node-version
# Install dependencies from `package.json`.
- name: Install Dependencies
id: install
run: npm install
# GitHub App authentication is required if you want to interact with any
# resources outside the scope of the repository this workflow runs in.
- name: Get GitHub App Token
id: token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.ISSUEOPS_APP_ID }}
private-key: ${{ secrets.ISSUEOPS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
# Remove any labels and start "fresh". This is important because the
# issue may have been closed and reopened.
- name: Remove Labels
id: remove-label
uses: issue-ops/labeler@v2
with:
action: remove
github_token: ${{ steps.token.outputs.token }}
labels: |
cancelled
confirmed
expired
validated
issue_number: ${{ github.event.issue.number }}
repository: ${{ github.repository }}
# Parse the issue body into machine-readable JSON, so that it can be
# processed by the rest of the workflow.
- name: Parse Issue body
id: parse
uses: issue-ops/parser@v4
with:
body: ${{ github.event.issue.body }}
issue-form-template: reservation.yml
workspace: ${{ github.workspace }}
# Validate early, and validate often! Validation should be run any time an
# issue is interacted with, to ensure that any changes to the issue body
# are valid.
- name: Validate Reservation Request
id: validate
uses: issue-ops/validator@v3
with:
add-comment: true
github-token: ${{ steps.token.outputs.token }}
issue-form-template: reservation.yml
issue-number: ${{ github.event.issue.number }}
parsed-issue-body: ${{ steps.parse.outputs.json }}
workspace: ${{ github.workspace }}
# If validation passed, add the validated label to the issue.
- if: ${{ steps.validate.outputs.result == 'success' }}
name: Add Validated Label
id: add-label
uses: issue-ops/labeler@v2
with:
action: add
github_token: ${{ steps.token.outputs.token }}
labels: |
validated
issue_number: ${{ github.event.issue.number }}
repository: ${{ github.repository }}
# Process the initial request.
- name: Process Reservation Request
id: process
# When using custom actions, make sure to pin the version to a specific
# commit or release tag!
uses: issue-ops/demo-reservation-action@main
with:
action: init
github_token: ${{ steps.token.outputs.token }}
issue_body: ${{ steps.parse.outputs.json }}
issue_template_path: .github/ISSUE_TEMPLATE/reservation.yml
project_number: 3