Merge pull request #77 from sevenwestmedia-labs/lambda_16 #186
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: Build & Test CI | |
concurrency: main | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
changes: ${{ steps.version.outputs.changes }} # map step output to job output | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
with: | |
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
fetch-depth: 0 | |
token: ${{ secrets.SERVICE_ACCOUNT_PAT }} | |
- name: Enable node | |
uses: actions/setup-node@master | |
with: | |
node-version: 16.x | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@wanews' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Version command | |
id: version | |
run: | | |
echo ::set-output name=changes::$(npx @changesets/cli version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true') | |
- name: Push changes | |
if: steps.version.outputs.changes == 'true' | |
run: | | |
git config user.email "github.serviceaccount@wanews.com.au" | |
git config user.name "SWM GitHub Service Account" | |
git add -A | |
git commit -m "Version packages" || echo "No changes to commit" | |
git push | |
build: | |
runs-on: ubuntu-latest | |
needs: version | |
if: always() && needs.version.outputs.changes == 'false' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
with: | |
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
fetch-depth: 0 | |
- name: Enable node | |
uses: actions/setup-node@master | |
with: | |
node-version: 16.x | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@wanews' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Install Pulumi CLI | |
uses: pulumi/action-install-pulumi-cli@v1 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ap-southeast-2 | |
role-to-assume: ${{ secrets.AWS_DEV_ACCOUNT_ROLE }} | |
role-skip-session-tagging: true | |
role-duration-seconds: 3600 | |
- name: Cache .pnpm-store | |
uses: actions/cache@v1 | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Install pnpm | |
run: | | |
npm i -g pnpm@8 | |
pnpm set verify-store-integrity false | |
- name: pnpm install | |
run: | | |
pnpm install --frozen-lockfile | |
- name: Type check | |
run: pnpm run build-tsc | |
- name: Lint types and code | |
run: pnpm run lint --quiet | |
- name: Run tests | |
run: pnpm test | |
- name: Package | |
run: pnpm package | |
- name: Release packages | |
uses: changesets/action@master | |
with: | |
publish: pnpm exec changeset publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.SERVICE_ACCOUNT_PAT }} |