feat: Configure basic Hydro survey stack #188
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: Build | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4.0.0 | |
with: | |
fetch-depth: 0 # Enable checking Git history | |
- name: Get Node.js version | |
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_ENV" | |
- name: Build and test with Node.js ${{ env.NODE_VERSION }} | |
uses: linz/action-typescript@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: 'https://npm.pkg.github.com' | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Get Python version | |
run: echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV" | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4.7.0 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install pre-commit | |
run: pip install pre-commit | |
- name: Lint files in non-${{ github.event.repository.default_branch }} branches | |
run: pre-commit run --all-files --verbose | |
if: github.ref != 'refs/heads/${{ github.event.repository.default_branch }}' | |
- name: Check all commit messages in non-${{ github.event.repository.default_branch }} branches | |
run: pre-commit run --hook-stage=manual --verbose | |
if: github.ref != 'refs/heads/${{ github.event.repository.default_branch }}' | |
deploy: | |
runs-on: ubuntu-22.04 | |
# Avoid parallel deployments of any single environment. | |
# This hack emulates AWS credentials assumption below. | |
concurrency: ${{ github.ref == 'refs/heads/master' }} | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4.0.0 | |
- name: Get Node.js version | |
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_ENV" | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3.8.1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: https://npm.pkg.github.com/ | |
scope: '@linz' | |
cache: npm | |
- name: Install production Node.js packages | |
run: npm ci --omit=dev | |
- name: Configure AWS Credentials | |
if: github.repository == 'linz/hydro-aws-infrastructure' | |
uses: aws-actions/configure-aws-credentials@v4.0.0 | |
with: | |
aws-region: ap-southeast-2 | |
role-to-assume: ${{ github.ref == 'refs/heads/master' && 'TBD' || 'arn:aws:iam::623931144233:role/ContinuousIntegration-GitHubActionsRole4F1BBA26-WDE0O3ZN93A6' }} | |
- name: Deploy | |
if: github.repository == 'linz/hydro-aws-infrastructure' | |
run: npm run cdk deploy --require-approval=never --role-arn=${{ github.ref == 'refs/heads/master' && 'TBD' || 'arn:aws:iam::623931144233:role/ContinuousIntegration-CiExecRoleAA6BFF70-CTEJ6J3L1NVU' }} --verbose |