feat: move to GHA #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push to Master | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' # Matches any tag that starts with 'v' and follows semantic versioning | |
- 'v*.*.*-rc*' | |
env: | |
BUCKET_NAME: 'autok3s-ui' | |
AWS_REGION: '${{ vars.AWS_REGION }}' | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/heads/')}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
role-session-name: upload-autok3s-ui | |
role-to-assume: arn:aws:iam::852061510766:role/github-actions-aws-s3-role | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/gallium | |
- name: build | |
run: | | |
npm install | |
npm run lint | |
UI_BASE_PATH=//s3-ap-southeast-2.amazonaws.com/autok3s-ui/static/ npm run build | |
- name: build static | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
./scripts/build-static | |
- name: Upload tgz file to s3 | |
if: startsWith(github.ref,'refs/tags/') | |
run: | | |
aws s3 cp "./dist/${GITHUB_REF#refs/tags/}.tag.gz" s3://${{ env.BUCKET_NAME }}/ --acl public-read | |
- name: Upload static to s3 | |
if: startsWith(github.ref,'refs/heads/') | |
run: | | |
aws s3 sync dist/static/ s3://${{ env.BUCKET_NAME }}/static/ --acl public-read --delete |