production-v2.0.01 #13
Workflow file for this run
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
name: Deploy to production if tagged as production release | |
on: | |
release: | |
types: [ released ] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
check_production_tag: | |
name: Check if the release is tagged as production | |
runs-on: ubuntu-latest | |
outputs: | |
has_production_tag: ${{ steps.check-production-tag.outputs.run_jobs }} | |
steps: | |
- name: check production tag ${{ github.ref }} | |
id: check-production-tag | |
run: | | |
if [[ ${{ github.ref }} =~ refs\/tags\/production ]]; then | |
echo "run_jobs=true" >> $GITHUB_OUTPUT | |
else | |
echo "run_jobs=false" >> $GITHUB_OUTPUT | |
fi | |
publish_production: | |
needs: [ check_production_tag ] | |
if: needs.check_production_tag.outputs.has_production_tag == 'true' | |
name: Publish image to ECR and update ECS stack | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: pc-reserve-poller | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
- name: Force ECS Update | |
run: | | |
aws ecs update-service --cluster pc-reserve-poller-production --service pc-reserve-poller-app-production --force-new-deployment |