Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add frontend redeploy task-def action (#1490)

sarayourfriendb26267474ae0
diff --git a/.github/actions/frontend-deploy/action.yml b/.github/actions/frontend-deploy/action.yml
new file mode 100644
index 000000000..bbb7dd7d7
--- /dev/null
+++ b/.github/actions/frontend-deploy/action.yml
@@ -0,0 +1,48 @@
+### !!!
+# 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.
+
+runs:
+ using: "composite"
+
+ steps:
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ aws-region: us-east-2
+
+ - name: Download task definition
+ with: shell
+ 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: true
diff --git a/.github/workflows/frontend_deploy.yml b/.github/workflows/frontend_deploy.yml
new file mode 100644
index 000000000..7a8112029
--- /dev/null
+++ b/.github/workflows/frontend_deploy.yml
@@ -0,0 +1,24 @@
+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: ./.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 }}