Skip to content

Bump websocket-driver from 0.8.0 to 0.8.2 (#393) #331

Bump websocket-driver from 0.8.0 to 0.8.2 (#393)

Bump websocket-driver from 0.8.0 to 0.8.2 (#393) #331

name: Deploy to AWS Staging
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
uses: ./.github/workflows/ci.yml
deploy:
name: deploy
needs: ["tests"]
environment: staging
runs-on: ubuntu-latest
env:
ECR_REPOSITORY: pya-staging-web
IMAGE_TAG: ${{ github.sha }}
INFRA_REPO: tax-benefits-backend
steps:
- run: echo 'Linter and tests passed.'
- run: echo 'Starting the staging deploy'
- name: Check out code
uses: actions/checkout@v6
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6.1.1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-east-1
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
BUNDLE_GITHUB__COM: ${{ secrets.DEPLOY_PAT }}
run: |
docker build -t 300423309117.dkr.ecr.us-east-1.amazonaws.com/pya-staging-web:${{env.IMAGE_TAG}} --secret id=github_pat,env=BUNDLE_GITHUB__COM --platform linux/amd64 .
docker push 300423309117.dkr.ecr.us-east-1.amazonaws.com/pya-staging-web:${{env.IMAGE_TAG}}
- name: Update SSM Version Parameter
run: |
echo "tag:$IMAGE_TAG"
aws ssm put-parameter \
--name /pya/staging/web/version \
--value "$IMAGE_TAG" \
--overwrite
- name: Get a deployment token
uses: actions/create-github-app-token@v3.1.1
id: token
with:
app-id: ${{ secrets.DEPLOYMENT_APP_ID }}
private-key: ${{ secrets.DEPLOYMENT_APP_KEY }}
owner: codeforamerica
repositories: tax-benefits-backend
- name: Trigger infrastructure deployment
uses: codex-/return-dispatch@v3
id: dispatch
with:
token: ${{ steps.token.outputs.token }}
# Update this to match the reference (branch, tag, or
# commit SHA) you want to deploy.
ref: main
# Replace this with the name of the target repository.
repo: tax-benefits-backend
owner: codeforamerica
# Replace this with the name of the workflow to call.
workflow: deploy.yaml
# Workflow inputs should be formatted as JSON. You can
# pass additional inputs as needed.
workflow_inputs: |
{
"environment": "pya-nonprod",
"config": "staging.pya.fileyourstatetaxes.org"
}
- name: Wait on Workflow
uses: lucasssvaz/wait-on-workflow@v1
id: waiter
with:
github-token: ${{ steps.token.outputs.token }}
repository: codeforamerica/${{ env.INFRA_REPO }}
workflow: ${{ steps.dispatch.outputs.run_id }}
- name: Fail unless the workflow succeeded
if: ${{ steps.waiter.outputs.conclusion != 'success' }}
uses: actions/github-script@v9
with:
script: |
core.setFailed('Deployment workflow completed with status: ${{ steps.waiter.outputs.conclusion }}')
- name: Notify deploy failure on Slack
uses: 8398a7/action-slack@v3
if: failure()
with:
text: "<!subteam^S06P99RGJDS> PYA staging deploy ${{ job.status }} :sob:"
status: ${{ job.status }}
fields: message,commit,author,workflow,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}