Publish Package to Github Packages & upload bundle to S3 #14
Workflow file for this run
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: Publish Package to Github Packages & upload bundle to S3 | |
on: | |
release: | |
types: [published] | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
publish_package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://npm.pkg.github.com' | |
# Defaults to the user or organization that owns the workflow file | |
scope: '@octocat' | |
- name: Publish the package | |
run: | | |
npm config set '//npm.pkg.github.com/:_authToken' "${{ secrets.GITHUB_TOKEN }}" | |
npm install | |
npm publish | |
s3_upload: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16.x' | |
# Speed up subsequent runs with caching | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install packages | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: yarn | |
- name: Build the bundle | |
run: yarn dist | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
- name: Upload files to S3 with AWS CLI | |
run: > | |
aws s3 cp dist s3://${{ secrets.AWS_S3_BUCKET }}/${{ github.ref_name }} | |
--recursive | |
--acl private | |
--cache-control "max-age=31536000" |