-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
102 lines (93 loc) · 2.97 KB
/
action.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Amplify action
description: |
Push or pull an amplify backend environment
inputs:
action:
description: "The action to perform"
required: true
aws_region:
description: "The AWS region"
required: true
default: "us-east-1"
amplify_env:
description: "The amplify environment"
required: true
amplify_app_id:
description: "The amplify app id"
required: true
role_arn:
description: "The role to assume"
required: true
skip_cli_install:
description: "Skip the installation of the amplify cli"
required: false
default: "false"
cli_version:
description: "The version of the amplify cli"
required: false
default: "latest"
deploy_command:
description: "The command to deploy the backend"
required: false
default: "amplify push --yes --force --allow-destructive-graphql-schema-updates --minify"
runs:
using: composite
steps:
- id: amplify
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ inputs.role_arn }}
role-session-name: GithubActionDeployment
output-credentials: true
- name: Install Amplify CLI
shell: bash
run: |
npm i -g @aws-amplify/cli@${{ inputs.cli_version }}
# Amplify CLI does not support headless pull with temporary credentials
# when useProfile is false.
# See: https://github.com/aws-amplify/amplify-cli/issues/11009.
- name: Create temp AWS profile
shell: bash
run: |
aws configure set aws_access_key_id ${{ steps.amplify.outputs.aws-access-key-id }} && \
aws configure set aws_secret_access_key ${{ steps.amplify.outputs.aws-secret-access-key }} && \
aws configure set aws_session_token ${{ steps.amplify.outputs.aws-session-token }} && \
aws configure set default.region ${{ inputs.aws_region }}
- name: Pull Amplify environment
shell: bash
run: |
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\",\
\"region\":\"$AWS_REGION\"\
}"
AMPLIFY="{\
\"appId\":\"$APP_ID\",\
\"envName\":\"$APP_ENV\",\
\"defaultEditor\":\"code\"\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG}"
if [[ $AMPLIFY_ACTION == 'pull' ]]; then
amplify pull \
--amplify $AMPLIFY \
--providers $PROVIDERS \
--yes
elif [[ $AMPLIFY_ACTION == 'push' ]]; then
amplify init \
--amplify $AMPLIFY \
--providers $PROVIDERS \
--yes
${{ inputs.deploy_command }}
fi
env:
AWS_REGION: ${{ inputs.aws_region }}
APP_ID: ${{ inputs.amplify_app_id }}
APP_ENV: ${{ inputs.amplify_env }}
AMPLIFY_ACTION: ${{ inputs.action }}
- name: Delete temp AWS Profile
shell: bash
run: rm -rf ~/.aws