name: Review app pipeline concurrency: group: review-${{ github.event.pull_request.number }} on: pull_request: types: - opened - synchronize - reopened - labeled workflow_dispatch: defaults: run: shell: bash jobs: hint: name: Add review app hint if: github.event.action == 'opened' && !contains(github.event.pull_request.labels.*.name, 'deploy-review') runs-on: ubuntu-latest permissions: pull-requests: write steps: - name: Comment on PR uses: actions/github-script@v7 with: script: | const msg = 'To deploy a review app for this PR, add the `deploy-review` label.'; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, }); if (!comments.find(c => c.body.startsWith('To deploy a review app'))) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: msg, }); } infra: name: Deploy review app infrastructure if: contains(github.event.pull_request.labels.*.name, 'deploy-review') uses: communitiesuk/submit-social-housing-lettings-and-sales-data-infrastructure/.github/workflows/create_review_app_infra.yml@main with: key: ${{ github.event.pull_request.number }} app_repo_role: arn:aws:iam::815624722760:role/core-application-repo permissions: id-token: write code: name: Deploy review app code needs: [infra] uses: ./.github/workflows/aws_deploy.yml with: aws_account_id: 837698168072 aws_role_prefix: core-dev aws_task_prefix: core-review-${{ github.event.pull_request.number }} concurrency_tag: ${{ github.event.pull_request.number }} environment: review permissions: id-token: write comment: name: Add link to PR if: contains(github.event.pull_request.labels.*.name, 'deploy-review') needs: [code] runs-on: ubuntu-latest permissions: issues: write pull-requests: write steps: - name: Comment on PR with URL uses: actions/github-script@v7 with: script: | const prNumber = context.issue.number; const msg = `Created review app at https://review.submit-social-housing-data.communities.gov.uk/${prNumber}. Note that the review app will be automatically deprovisioned after 30 days and will need the review app pipeline running again.`; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, }); if (!comments.find(c => c.body.startsWith('Created review app at'))) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, body: msg, }); }