-
Notifications
You must be signed in to change notification settings - Fork 17
45 lines (45 loc) · 1.74 KB
/
deploy-frontend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Deploy frontend to AWS Amplify
on:
workflow_call:
outputs:
revert_command:
description: "Command to revert frontend deployment"
value: ${{ jobs.deploy-frontend.outputs.revert_cmd }}
env:
APP_ID: d3k3b7zs07zjio
jobs:
deploy-frontend:
runs-on: ubuntu-latest
outputs:
revert_cmd: ${{ steps.generate-revert-command.outputs.revert_cmd }}
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_DEFAULT_REGION }}
- name: Extract branch name
shell: bash
run: |
echo "Running on branch ${{ github.ref }}"
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
echo "branch=master" >> $GITHUB_OUTPUT
else
echo "branch=staging" >> $GITHUB_OUTPUT
fi
id: extract_branch
- name: Generate revert command
id: generate-revert-command
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
aws amplify list-jobs --app-id $APP_ID --branch-name $BRANCH --max-items 1 | jq '.jobSummaries[0]' | echo
JOB_ID=$(aws amplify list-jobs --app-id $APP_ID --branch-name $BRANCH --max-items 1 | jq '.jobSummaries[0].jobId')
echo "revert_cmd=aws amplify start-job --app-id $APP_ID --branch-name $BRANCH --job-id $JOB_ID --job-type RETRY" >> $GITHUB_OUTPUT
- name: Deploy
shell: bash
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: ./scripts/amplify-deploy.sh $APP_ID $BRANCH