Update S3 sync command for dbconfig.yml and migrations #9
This file contains hidden or 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: Build and Deploy | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main, "feat/cd" ] | |
| jobs: | |
| test: | |
| name: Tests | |
| uses: ./.github/workflows/ci.yaml | |
| build-and-push: | |
| name: Build and Push | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Login to Amazon ECR Public | |
| id: login-ecr-public | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| with: | |
| registry-type: public | |
| - name: Build and Push Image | |
| env: | |
| REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} | |
| REGISTRY_ALIAS: d0w1o5s2 | |
| REPOSITORY: ubcea/echo-base | |
| TAG: ${{ github.sha }} | |
| run: | | |
| docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$TAG -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:latest . | |
| docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY --all-tags | |
| sync-migrations: | |
| name: Sync Migrations | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v3 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Sync dbconfig.yml and migrations | |
| run: aws s3 sync . s3://echo-base/${{ github.sha }}/ --exclude '*' --include "dbconfig.yml" --include "migrations/*" | |
| - name: Sync migrations | |
| run: aws s3 sync ./migrations s3://echo-base/${{ github.sha }}/migrations --delete | |
| decision-gate: | |
| name: Decision Gate | |
| needs: | |
| - build-and-push | |
| - sync-migrations | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Pass | |
| run: | | |
| echo "decision gate passed" | |
| exit 0 | |
| deploy: | |
| name: Deploy to EC2 | |
| needs: decision-gate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Stub | |
| run: | | |
| echo "not implemented" | |
| exit 1 |