Skip to content

add functions to re-encrypt using a new key to prepare for key rotation #161

add functions to re-encrypt using a new key to prepare for key rotation

add functions to re-encrypt using a new key to prepare for key rotation #161

name: Test, Deploy, Publish
on:
push:
branches: [ '**' ]
tags: [ 'v*' ]
paths-ignore:
- 'terraform/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test
run: docker compose run app go test ./...
lint:
name: Lint and Vulnerability Scan
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
deploy:
name: Deploy to AWS Lambda
needs: [ 'tests', 'lint' ]
if: github.ref_name == 'main' || github.ref_name == 'develop'
environment: ${{ github.ref_name }}
runs-on: ubuntu-latest
concurrency:
group: deploy-${{ github.ref }}-${{ matrix.region }}
cancel-in-progress: false
strategy:
matrix:
region: [ us-east-1, us-west-2 ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy
run: |
docker compose run \
-e LAMBDA_ROLE=${{ vars.LAMBDA_ROLE }} \
-e API_KEY_TABLE=${{ vars.API_KEY_TABLE }} \
-e TOTP_TABLE=${{ vars.TOTP_TABLE }} \
-e WEBAUTHN_TABLE=${{ vars.WEBAUTHN_TABLE }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
app ./scripts/deploy.sh ${{ matrix.region }} ${{ vars.STAGE }}
build-and-publish:
name: Build and Publish
needs: [ 'tests', 'lint' ]
if: github.ref_name == 'main' || github.ref_name == 'develop'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major.minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}