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 ponder to Treasure Environments | |
on: | |
push: | |
branches: | |
- main | |
- terraform | |
tags: | |
- ponder-v* | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'production' || 'development' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
id: aws_creds | |
with: | |
role-to-assume: ${{ vars.AWS_ROLE_ARN }} | |
aws-region: ${{ vars.AWS_REGION }} | |
output-credentials: true | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Get Commit SHA | |
id: ghsha | |
shell: bash | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} | |
IMAGE_TAG: ${{ steps.ghsha.outputs.sha_short }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
sed -i 's|DOCKER_IMAGE|'"$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"'|g' Dockerrun.aws.json | |
zip deploy.zip Dockerrun.aws.json | |
- name: Deploy to EB | |
uses: einaregilsson/beanstalk-deploy@v22 | |
with: | |
aws_access_key: ${{ steps.aws_creds.outputs.aws-access-key-id }} | |
aws_secret_key: ${{ steps.aws_creds.outputs.aws-secret-access-key }} | |
aws_session_token: ${{ steps.aws_creds.outputs.aws-session-token }} | |
application_name: ponder | |
use_existing_version_if_available: true | |
environment_name: ${{ vars.EB_ENVIRONMENT }} | |
version_label: ${{ steps.ghsha.outputs.sha_short }} | |
region: ${{ vars.AWS_REGION }} | |
deployment_package: deploy.zip |