Skip to content

change placeholderData to initialData and remove staleTime for airpor… #114

change placeholderData to initialData and remove staleTime for airpor…

change placeholderData to initialData and remove staleTime for airpor… #114

Workflow file for this run

name: 'Deploy'
on:
push:
branches:
- 'main'
paths-ignore:
- 'go/proxy/**'
env:
WORKSPACE_ARTIFACT_API: 'explore_flights_api_artifact'
WORKSPACE_ARTIFACT_CRON: 'explore_flights_cron_artifact'
WORKSPACE_ARTIFACT_UI: 'explore_flights_ui_artifact'
WORKSPACE_ARTIFACT_CDK: 'explore_flights_cdk_artifact'
jobs:
build_and_test_api:
name: 'Build and test API'
runs-on: ubuntu-latest
env:
GOOS: 'linux'
GOARCH: 'arm64' # keep this in sync with the arch configured in CDK!
CGO_ENABLED: '1' # required by graphviz
CC: 'aarch64-linux-gnu-gcc'
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup go'
uses: actions/setup-go@v5
with:
go-version-file: 'go/api/go.mod'
cache-dependency-path: 'go/api/go.sum'
- name: 'Install cross-compilation tools'
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: 'aarch64-unknown-linux-gnu'
- name: 'Test'
working-directory: 'go/api'
run: 'go test ./...'
- name: 'Build'
working-directory: 'go/api'
run: |
go build --ldflags '-extldflags "-static"' -o bootstrap -tags "lambda"
- name: 'Store API artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_API }}
path: 'go/api/bootstrap'
retention-days: 1
build_and_test_cron:
name: 'Build and test cron'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup go'
uses: actions/setup-go@v5
with:
go-version-file: 'go/cron/go.mod'
cache-dependency-path: 'go/cron/go.sum'
- name: 'Test'
working-directory: 'go/cron'
run: 'go test ./...'
- name: 'Build'
working-directory: 'go/cron'
env:
GOOS: 'linux'
GOARCH: 'arm64' # keep this in sync with the arch configured in CDK!
CGO_ENABLED: '0'
run: |
go build -o bootstrap -tags "lambda,lambda.norpc"
- name: 'Store cron artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_CRON }}
path: 'go/cron/bootstrap'
retention-days: 1
build_ui:
name: 'Build UI'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'Install npm dependencies'
working-directory: 'ui'
run: 'npm install'
- name: 'Build'
working-directory: 'ui'
run: 'npm run build'
- name: 'Prepare UI resources bundle'
working-directory: 'ui/dist'
run: 'zip -r ../${{ env.WORKSPACE_ARTIFACT_UI }}.zip .'
- name: 'Store UI artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_UI }}
path: 'ui/${{ env.WORKSPACE_ARTIFACT_UI }}.zip'
retention-days: 1
build_and_synth_cdk:
name: 'Build and synth cdk'
runs-on: ubuntu-latest
needs:
- build_and_test_api
- build_and_test_cron
- build_ui
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Download API artifact'
uses: actions/download-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_API }}
path: .
- name: 'Prepare API lambda bundle'
run: '(chmod +x bootstrap && zip -q cdk/api_lambda_bundle.zip bootstrap && rm bootstrap)'
- name: 'Download cron artifact'
uses: actions/download-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_CRON }}
path: .
- name: 'Prepare cron lambda bundle'
run: '(chmod +x bootstrap && zip -q cdk/cron_lambda_bundle.zip bootstrap && rm bootstrap)'
- name: 'Download UI artifact'
uses: actions/download-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_UI }}
path: 'cdk/'
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'Install npm dependencies'
working-directory: 'cdk'
run: 'npm install'
- name: 'Build'
working-directory: 'cdk'
run: 'npm run build'
- name: 'Install cdk'
working-directory: 'cdk'
run: 'npm install -g aws-cdk'
- name: 'Synth cdk'
working-directory: 'cdk'
run: 'cdk synth --app bin/cdk.js'
- name: 'Store cdk synth artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_CDK }}
path: |
cdk/cdk.out/
cdk/cdk.json
retention-days: 1
deploy:
name: 'Deploy'
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: 'prod'
permissions:
id-token: write
needs:
- build_and_synth_cdk
steps:
- name: 'Download cdk synth artifact'
uses: actions/download-artifact@v4
with:
name: ${{ env.WORKSPACE_ARTIFACT_CDK }}
path: .
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 'Install cdk'
run: 'npm install -g aws-cdk'
- name: 'AWS Credentials'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_CDK_ROLE }}
aws-region: ${{ secrets.AWS_CDK_REGION }}
- name: 'Deploy'
run: |
cdk --app ./cdk.out deploy --require-approval never "Data-Prod" "Website-Prod" "Cron-Prod" "Route53-Prod" --parameters "Cron-Prod:lhApiClientId=${{ secrets.LH_API_CLIENT_ID }}" --parameters "Cron-Prod:lhApiClientSecret=${{ secrets.LH_API_CLIENT_SECRET }}" --parameters "Cron-Prod:webhookUrl=${{ secrets.WEBHOOK_URL }}"