-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
110 lines (99 loc) · 3.16 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
103
104
105
106
107
108
109
110
name: 'AWS S3 multibranch deploy preview'
description: '🚀 Easily deploy a preview of each branch of your static site to a single AWS S3 bucket'
branding:
color: 'green'
icon: 'upload-cloud'
inputs:
aws_region:
description: 'AWS region of the S3 bucket'
default: 'us-east-1'
required: true
aws_assume_role:
description: 'ARN of the role to be assumed'
default: ''
required: true
aws_bucket:
description: 'Name of the S3 bucket'
default: ''
required: true
folder:
description: 'Folder to be deployed in S3 bucket'
default: './site'
required: true
max_branch_deployed:
description: 'Maximum number of branches to be deployed'
default: '50'
required: false
max_commit_per_branch_deployed:
description: 'Maximum number of commit per branch to be deployed'
default: '10'
required: false
prefix:
description: 'Prefix path for base url'
default: ''
required: false
generate_prefix:
description: 'Generate prefix for each branch'
default: 'false'
required: false
enable_comment:
description: 'Enable comment to PR'
default: 'true'
required: false
github_token:
description: 'GitHub token, requried to create PR comments with generated preview URL'
default: ''
required: false
outputs:
preview_url:
description: 'URL of the deployed preview'
value: ${{ steps.deploy.outputs.preview_url }}
prefix:
description: 'Generated prefix'
value: ${{ steps.prefix.outputs.prefix }}
runs:
using: composite
steps:
- name: configure AWS credentials
id: creds
if: ${{ inputs.generate_prefix == 'false' }}
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ inputs.aws_assume_role }}
role-session-name: samplerolesession
aws-region: ${{ inputs.aws_region }}
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: Generate prefix
if: ${{ inputs.generate_prefix == 'true' }}
id: prefix
run: generate_prefix.sh
shell: bash
- name: Deploy preview
id: deploy
if: ${{ inputs.generate_prefix == 'false' }}
shell: bash
run: entrypoint.sh
env:
INPUT_AWS_BUCKET: ${{ inputs.aws_bucket }}
INPUT_AWS_REGION: ${{ inputs.aws_region }}
INPUT_FOLDER: ${{ inputs.folder }}
INPUT_MAX_BRANCH_DEPLOYED: ${{ inputs.max_branch_deployed }}
INPUT_MAX_COMMIT_PER_BRANCH_DEPLOYED: ${{ inputs.max_commit_per_branch_deployed }}
INPUT_PREFIX: ${{ inputs.prefix }}
- name: Post comment to PR
if: ${{ inputs.generate_prefix == 'false' && inputs.enable_comment == 'true' && github.event_name == 'pull_request' }}
uses: actions/github-script@v3
with:
github-token: ${{ inputs.github_token }}
script: |
const shortSha = context.sha.substring(0, 7);
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `✅ Preview deployed at ${{ steps.deploy.outputs.preview_url }} successfully for revision ${shortSha} 🚀`
})