Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix staging frontend deployment (#1555)
sarayourfriend079ab7b2622b
diff --git a/.github/actions/frontend-deploy/action.yml b/.github/actions/frontend-deploy/action.ymldeleted file mode 100644index 93758f0d5..000000000--- a/.github/actions/frontend-deploy/action.yml+++ /dev/null@@ -1,52 +0,0 @@-### !!!-# This file is automatically generated using Terraform.-# Do not update it manually. If changes need to be made,-# please request help from a maintainer to generate the-# updated version.-### !!!--name: openverse/staging-frontend-nuxt-deploy-description: Update the task definition for a staging-frontend-nuxt deployment--inputs:- tag:- required: true- description: Image tag to deploy.- aws_access_key_id:- required: true- aws_secret_access_key:- required: true--runs:- using: "composite"-- steps:- - name: Configure AWS credentials- uses: aws-actions/configure-aws-credentials@v1- with:- aws-access-key-id: ${{ inputs.aws_access_key_id }}- aws-secret-access-key: ${{ inputs.aws_secret_access_key }}- aws-region: us-east-2-- - name: Download task definition- shell: bash- run: |- aws ecs describe-task-definition \- --task-definition staging-frontend \- --query taskDefinition > task-definition.json-- - name: Fill in the new image ID in the Amazon ECS task definition- id: task-def- uses: aws-actions/amazon-ecs-render-task-definition@v1- with:- task-definition: task-definition.json- container-name: nuxt- image: ghcr.io/wordpress/openverse-frontend:${{ inputs.tag }}-- - name: Deploy Amazon ECS task definition- uses: aws-actions/amazon-ecs-deploy-task-definition@v1- with:- task-definition: ${{ steps.task-def.outputs.task-definition }}- service: staging-frontend- cluster: staging-default- wait-for-service-stability: truediff --git a/.github/actions/staging-frontend-deploy/action.yml b/.github/actions/staging-frontend-deploy/action.ymlnew file mode 100644index 000000000..12f59253a--- /dev/null+++ b/.github/actions/staging-frontend-deploy/action.yml@@ -0,0 +1,136 @@+### !!!+# This file is automatically generated using Terraform.+# Do not update it manually. If changes need to be made,+# please request help from a maintainer to generate the+# updated version.+### !!!++name: openverse/staging-frontend-nuxt-deploy+description: Update the task definition for a staging-frontend-nuxt deployment++inputs:+ tag:+ required: true+ description: Image tag to deploy.+ aws-access-key-id:+ required: true+ aws-secret-access-key:+ required: true+ slack-webhook:+ required: false++runs:+ using: "composite"++ steps:+ - name: Notify deployment start+ uses: slackapi/[email protected]+ with:+ payload: |+ {+ "text": "Starting deployment of staging-frontend",+ "blocks": [+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": ":spinning-cd: A deployment of staging-frontend is starting using the `${{ inputs.tag }}` tag."+ }+ },+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to monitor the deployment>."+ }+ }+ ]+ }+ env:+ SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }}+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK++ - name: Configure AWS credentials+ uses: aws-actions/configure-aws-credentials@v1+ with:+ aws-access-key-id: ${{ inputs.aws-access-key-id }}+ aws-secret-access-key: ${{ inputs.aws-secret-access-key }}+ aws-region: us-east-1++ - name: Download task definition template+ shell: bash+ run: |+ aws ecs describe-task-definition \+ --task-definition staging-frontend-template \+ --query taskDefinition > task-definition.json++ - name: Fill in the new image ID in the Amazon ECS task definition+ id: task-def+ uses: aws-actions/amazon-ecs-render-task-definition@v1+ with:+ task-definition: task-definition.json+ container-name: nuxt+ image: ghcr.io/wordpress/openverse-frontend:${{ inputs.tag }}++ - name: Deploy Amazon ECS task definition+ uses: aws-actions/amazon-ecs-deploy-task-definition@v1+ with:+ task-definition: ${{ steps.task-def.outputs.task-definition }}+ service: staging-frontend+ cluster: staging-default+ wait-for-service-stability: true++ - name: Notify deployment finished+ uses: slackapi/[email protected]+ with:+ payload: |+ {+ "text": "Deployment of staging-frontend successful",+ "blocks": [+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": ":tadaco: The deployment of staging-frontend using the `${{ inputs.tag }}` tag *succeeded*."+ }+ },+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to review the completed deployment workflow>."+ }+ }+ ]+ }+ env:+ SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }}+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK++ - name: Notify deployment failure+ if: failure()+ uses: slackapi/[email protected]+ with:+ payload: |+ {+ "text": "Deployment of staging-frontend failed!",+ "blocks": [+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": ":alert: The deployment of staging-frontend using the `${{ inputs.tag }}` tag *failed* :alert:"+ }+ },+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to review the failed deployment workflow>."+ }+ }+ ]+ }+ env:+ SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }}+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOKdiff --git a/.github/workflows/frontend_deploy.yml b/.github/workflows/frontend_deploy.ymldeleted file mode 100644index 097d76aec..000000000--- a/.github/workflows/frontend_deploy.yml+++ /dev/null@@ -1,28 +0,0 @@-name: Update frontend task definition (redeploy)--on:- push:- branches:- - main- release:- types:- - "released"- workflow_dispatch:- inputs:- tag:- description: Tag of the ghcr.io/wordpress/openverse-frontend image to use.- required: true--jobs:- update-task-definition-and-deploy:- name: Update task definition and deploy- runs-on: ubuntu-latest-- steps:- - uses: actions/checkout@v3-- - uses: ./.github/actions/frontend-deploy- with:- tag: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.sha) || (github.event_name == 'push' && 'main') || github.event.release.tag_name }}- aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}- aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}diff --git a/.github/workflows/staging_frontend_deploy.yml b/.github/workflows/staging_frontend_deploy.ymlnew file mode 100644index 000000000..99c2fa32d--- /dev/null+++ b/.github/workflows/staging_frontend_deploy.yml@@ -0,0 +1,21 @@+name: Redeploy staging frontend++on:+ push:+ branches:+ - main++jobs:+ update-task-definition-and-deploy:+ name: Update task definition and deploy+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v3++ - uses: ./.github/actions/staging-frontend-deploy+ with:+ tag: "main"+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}+ slack-webhook: ${{ secrets.SLACK_WEBHOOK_URL }}