generated from web-illinois/toolkit-template
-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (61 loc) · 2.94 KB
/
deploy_production.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
name: deploy_production
on:
push:
tags: [ '**' ]
env:
MAJORVERSION: ''
MINORVERSION: ''
FULLVERSION: ''
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: 'Get Version'
id: get_version
uses: battila7/get-version-action@v2
- name: 'Check for correct naming convention'
if: ${{ !steps.get_version.outputs.is-semver }}
run: exit 1
- name: 'Get major version from tag'
run: echo "MAJORVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
- name: 'Get minor version from tag'
run: echo "MINORVERSION=${GITHUB_BRANCH}.${GITHUB_BRANCH_MINOR}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
GITHUB_BRANCH_MINOR: ${{ steps.get_version.outputs.minor }}
- name: Get patch (full) version from tag
run: echo "FULLVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.version-without-v }}
- name: Display major version install
run: echo "Installing major version ${MAJORVERSION}"
- name: Display minor version install
run: echo "Installing minor version ${MINORVERSION}"
- name: Display patch (full) version install
run: echo "Installing patch (full) version ${FULLVERSION}"
- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2
- name: Deploy toolbox to S3 bucket for major version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MAJORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for major version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MAJORVERSION*"
- name: Deploy toolbox to S3 bucket for minor version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MINORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for minor version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MINORVERSION*"
- name: Deploy toolbox to S3 bucket for patch (full) version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for patch (full) version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$FULLVERSION*"