chore: convert root template to .heex #2637
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uses label to decide which environment to deploy to. | |
# e.g. "dev-blue" or "dev-green" | |
name: "Deploy: PR" | |
on: | |
pull_request: | |
types: | |
- synchronize | |
- labeled | |
env: | |
# deploy only if any PR label is "dev-green" or "dev-blue" | |
DO_DEPLOY: ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') || contains(github.event.pull_request.labels.*.name, 'dev-blue') }} | |
# really hacky expression because Github Actions | |
# lacks real conditional statements | |
DEPLOY_ENV: ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') && 'dev-green' || 'dev-blue' }} | |
concurrency: | |
group: ${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
pr: | |
# env not available for job if | |
if: ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') || contains(github.event.pull_request.labels.*.name, 'dev-blue') }} | |
uses: ./.github/workflows/use-deploy-ecs.yml | |
with: | |
deployment-env: ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') && 'dev-green' || 'dev-blue' }} # env not valid here either | |
secrets: | |
aws-account-id: ${{ secrets.TID_AWS_ACCOUNT_ID }} | |
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }} | |
docker-repo: ${{ secrets.DOCKER_REPO }} | |
notify: | |
needs: [pr] | |
uses: ./.github/workflows/use-notify-slack.yml | |
if: ${{ success() || failure() }} | |
secrets: | |
slack-webhook: ${{ secrets.SLACK_WEBHOOK }} | |
with: | |
job-status: ${{ needs.pr.result }} | |
success-message: | | |
PR#${{ github.event.pull_request.number }} (`${{ github.ref_name }}` branch) deployed to ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') && 'dev-green' || 'dev-blue' }} | |
failure-message: | | |
PR#${{ github.event.pull_request.number }} failed to deploy to ${{ contains(github.event.pull_request.labels.*.name, 'dev-green') && 'dev-green' || 'dev-blue' }} | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: [pr] | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Unlabel other PRs (if needed) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ env.DO_DEPLOY }} | |
run: | | |
gh pr list --repo ${{ github.repository }} --state all --label "${{ env.DEPLOY_ENV }}" --json number --jq ".[].number"| while read -r pr_number ; do | |
if [[ "${pr_number}" != "${{ github.event.pull_request.number }}" ]]; then | |
echo "=== PR ${pr_number} : remove ${{ env.DEPLOY_ENV }} label ===" | |
gh pr edit "${pr_number}" --repo ${{ github.repository }} --remove-label "${{ env.DEPLOY_ENV }}" | |
fi | |
done |