-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (108 loc) · 3.94 KB
/
deploy-library.yml
File metadata and controls
115 lines (108 loc) · 3.94 KB
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
111
112
113
114
115
name: Deploy library
on:
push:
tags: [ v* ]
branches: [ main ]
jobs:
vars:
runs-on: ubuntu-latest
steps:
- id: tag_version
run: |
REF=$(echo $GITHUB_REF | cut -d / -f 3)
[[ "$GITHUB_REF" =~ ^refs/tags.*$ ]] && VERSION="$REF" || VERSION="${REF}-${GITHUB_SHA::7}"
echo ::set-output name=version::$(echo "$VERSION")
- id: send-message
uses: archive/github-actions-slack@master
with:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: deployments
slack-text: Deployment of ${{ github.repository }} has begun.
env:
INPUT_SLACK-OPTIONAL-blocks: |
[
{ type: 'section', text: { type: 'mrkdwn', text: 'A deployment for *${{ github.repository }}* has begun.' } },
{ type: 'divider' },
{ type: 'section', fields: [
{ type: 'mrkdwn', text: '*Version:*\n${{ steps.tag_version.outputs.version }}' },
{ type: 'mrkdwn', text: '*Author:*\n${{ github.triggering_actor }}' },
]},
{ type: 'divider' },
{
type: 'section',
text: { type: 'mrkdwn', text: '${{ github.workflow}} #${{ github.run_id }}' },
accessory: { type: 'button', text: { type: 'plain_text', text: 'View Deployment' }, url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id}}' },
},
]
outputs:
version: ${{ steps.tag_version.outputs.version }}
slack-channel: ${{ fromJson(steps.send-message.outputs.slack-result).response.channel }}
slack-thread: ${{ fromJson(steps.send-message.outputs.slack-result).response.message.ts }}
post-deploy-failure:
if: failure()
needs: [vars, deploy]
runs-on: ubuntu-latest
steps:
- name: Notify failure
uses: archive/github-actions-slack@master
with:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: ${{ needs.vars.outputs.slack-channel }}
slack-text: Deployment failed!
slack-optional-thread_ts: ${{ needs.vars.outputs.slack-thread }}
slack-optional-reply_broadcast: true
post-deploy-success:
if: success()
needs: [vars, deploy]
runs-on: ubuntu-latest
steps:
- name: Notify success
uses: archive/github-actions-slack@master
with:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: ${{ needs.vars.outputs.slack-channel }}
slack-text: Deployment complete.
slack-optional-thread_ts: ${{ needs.vars.outputs.slack-thread }}
# Build
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.x
- uses: actions/cache@v2
id: yarn-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Build Widget
run: yarn build
- name: Archive Widget
uses: actions/upload-artifact@v2
with:
name: compiled-assets
path: |
dist
deploy:
runs-on: ubuntu-latest
needs: [vars, build]
steps:
- name: Download compiled assets
uses: actions/download-artifact@v2
with:
name: compiled-assets
- uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --cache-control max-age=31536000,public
env:
AWS_S3_BUCKET: cdn.parameter1.com
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DEST_DIR: 'deferred-script-loader/${{ needs.vars.outputs.version }}'