Gift Exchange virtuals #10
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 | |
on: | |
push: | |
tags: ['v*'] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} | |
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | |
- name: Login to registry | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build image | |
run: docker build -t ${{steps.login-ecr.outputs.registry}}/giftr/giftr-api:${{github.ref_name}} . | |
- name: Push image to registry | |
run: docker push ${{steps.login-ecr.outputs.registry}}/giftr/giftr-api:${{github.ref_name}} | |
- name: Build Dockerrun.aws.json | |
run: node generate-dockerrun.mjs --image ${{steps.login-ecr.outputs.registry}}/giftr/giftr-api:${{github.ref_name}} --port 3000:3000 | |
- name: Pack | |
run: zip -r giftr-api-build-${{github.ref_name}}.zip Dockerrun.aws.json | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: gh release create ${{github.ref_name}} --repo="$GITHUB_REPOSITORY" --title="${{github.ref_name}} - ${{github.event.head_commit.message}}" --generate-notes | |
- name: Upload artifacts | |
uses: actions/[email protected] | |
with: | |
name: builds | |
path: giftr-api-build-${{github.ref_name}}.zip | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifacts | |
uses: actions/[email protected] | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} | |
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | |
- name: Upload build | |
run: aws s3 cp "builds/giftr-api-build-${{github.ref_name}}.zip" s3://elasticbeanstalk-us-east-1-${{secrets.AWS_ACCOUNT_ID}}/artifacts/giftr-api/ | |
- name: Create version | |
run: aws elasticbeanstalk create-application-version --application-name ${{secrets.ELASTIC_BEANSTALK_NAME}} --version-label ${{github.ref_name}} --description ${{github.ref_name}} --source-bundle S3Bucket="elasticbeanstalk-us-east-1-${{secrets.AWS_ACCOUNT_ID}}",S3Key="artifacts/giftr-api/giftr-api-build-${{github.ref_name}}.zip" | |
- name: Update environment | |
run: | | |
aws elasticbeanstalk update-environment --application-name ${{secrets.ELASTIC_BEANSTALK_NAME}} --environment-name ${{secrets.ELASTIC_BEANSTALK_ENV_NAME}} --version-label ${{github.ref_name}} --option-settings Namespace=aws:elasticbeanstalk:application:environment,OptionName=DOPPLER_TOKEN,Value=${{secrets.DOPPLER_TOKEN}} | |
aws elasticbeanstalk wait environment-updated --application-name ${{secrets.ELASTIC_BEANSTALK_NAME}} --environment-name ${{secrets.ELASTIC_BEANSTALK_ENV_NAME}} |