Skip to content

Commit 7193937

Browse files
Refactor deploy workflow to include permissions and reuse
Updated deploy workflow to use component_deploy.yml and set permissions.
1 parent 63a0a7b commit 7193937

1 file changed

Lines changed: 9 additions & 110 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,115 +2,14 @@ name: deploy
22
on:
33
release:
44
types: [published]
5-
env:
6-
MAJORVERSION: ''
7-
MINORVERSION: ''
8-
FULLVERSION: ''
9-
PRERELEASE: ''
10-
COMPONENT_NAME: ${{ github.event.repository.name }}
115
jobs:
126
build:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: 'Checkout GitHub Action'
16-
uses: actions/checkout@v4
17-
- name: 'Get Version'
18-
id: get_version
19-
uses: dhkatz/get-version-action@v3.0.0
20-
21-
- name: 'Check for correct naming convention'
22-
if: ${{ !steps.get_version.outputs.is-semver }}
23-
run: exit 1
24-
- name: 'Get major version from tag'
25-
run: echo "MAJORVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
26-
env:
27-
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
28-
- name: 'Get minor version from tag'
29-
run: echo "MINORVERSION=${GITHUB_BRANCH}.${GITHUB_BRANCH_MINOR}" >> $GITHUB_ENV
30-
env:
31-
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
32-
GITHUB_BRANCH_MINOR: ${{ steps.get_version.outputs.minor }}
33-
- name: Get patch (full) version from tag
34-
run: echo "FULLVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
35-
env:
36-
GITHUB_BRANCH: ${{ steps.get_version.outputs.version-without-v }}
37-
- name: Get prelease version from tag
38-
run: echo "PRERELEASE=${GITHUB_BRANCH}" >> $GITHUB_ENV
39-
env:
40-
GITHUB_BRANCH: ${{ steps.get_version.outputs.prerelease }}
41-
- name: Display major version install
42-
run: echo "Installing major version ${MAJORVERSION} for ${COMPONENT_NAME}"
43-
- name: Display minor version install
44-
run: echo "Installing minor version ${MINORVERSION} for ${COMPONENT_NAME}"
45-
- name: Display patch (full) version install
46-
run: echo "Installing patch (full) version ${FULLVERSION} for ${COMPONENT_NAME}"
47-
- name: Production run
48-
if: ${{ steps.get_version.outputs.prerelease == '' }}
49-
run: echo "Running production deployment"
50-
- name: Prerelease run
51-
if: ${{ steps.get_version.outputs.prerelease != '' }}
52-
run: echo "Running development deployment"
53-
54-
- run: npm install
55-
- run: npm rebuild
56-
- run: npm run-script build
57-
58-
# Run this to get the axe report
59-
# This only uses Chrome, so it doesn't have to run the full Playwright install
60-
- name: Run axe-core tests
61-
run: npm run test:axe:github
62-
63-
- name: Configure AWS Credentials
64-
uses: aws-actions/configure-aws-credentials@v1
65-
with:
66-
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
67-
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
68-
aws-region: us-east-2
69-
70-
- name: Deploy toolbox to S3 bucket for major version
71-
if: ${{ steps.get_version.outputs.prerelease == '' }}
72-
run: aws s3 sync ./dist/cdn/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MAJORVERSION --delete --acl bucket-owner-full-control
73-
- name: Invalidate Cloudfront cache for major version
74-
if: ${{ steps.get_version.outputs.prerelease == '' }}
75-
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MAJORVERSION*"
76-
- name: Deploy toolbox to S3 bucket for minor version
77-
if: ${{ steps.get_version.outputs.prerelease == '' }}
78-
run: aws s3 sync ./dist/cdn/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MINORVERSION --delete --acl bucket-owner-full-control
79-
- name: Invalidate Cloudfront cache for minor version
80-
if: ${{ steps.get_version.outputs.prerelease == '' }}
81-
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MINORVERSION*"
82-
- name: Deploy toolbox to S3 bucket for patch (full) version
83-
if: ${{ steps.get_version.outputs.prerelease == '' }}
84-
run: aws s3 sync ./dist/cdn/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
85-
- name: Invalidate Cloudfront cache for patch (full) version
86-
if: ${{ steps.get_version.outputs.prerelease == '' }}
87-
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$FULLVERSION*"
88-
- name: Deploy toolbox to S3 bucket for full version dev
89-
if: ${{ steps.get_version.outputs.prerelease != '' }}
90-
run: aws s3 sync ./dist/cdn/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
91-
- name: Invalidate Cloudfront cache for full version dev
92-
if: ${{ steps.get_version.outputs.prerelease != '' }}
93-
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$FULLVERSION*"
94-
- name: Deploy toolbox to S3 bucket for latest dev
95-
if: ${{ steps.get_version.outputs.prerelease != '' }}
96-
run: aws s3 sync ./dist/cdn/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/latest --delete --acl bucket-owner-full-control
97-
- name: Invalidate Cloudfront cache for latest dev
98-
if: ${{ steps.get_version.outputs.prerelease != '' }}
99-
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/latest*"
100-
101-
publish:
102-
needs: build
103-
runs-on: ubuntu-latest
104-
steps:
105-
- name: 'Checkout GitHub Action'
106-
uses: actions/checkout@v4
107-
- uses: actions/setup-node@v4
108-
with:
109-
node-version: '22.x'
110-
registry-url: 'https://registry.npmjs.org'
111-
- name: Install dependencies
112-
run: npm ci
113-
- name: Install to npm
114-
run: npm publish --access public
115-
env:
116-
NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}}
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
id-token: write # Required for NPM Publish OIDC
11+
uses: web-illinois/toolkit-management/.github/workflows/component_deploy.yml@main
12+
with:
13+
COMPONENT_NAME: ${{github.event.repository.name}}
14+
secrets:
15+
TOOLKIT_AWS_ACCESS_SECRET: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}

0 commit comments

Comments
 (0)