This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
Update react monorepo #347
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: Deploy | |
on: | |
- push | |
jobs: | |
containers: | |
name: Containers | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
app: | |
- api | |
- tasks | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-buildx-${{ matrix.app }}-${{ hashFiles('**/poetry.lock') }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker-buildx-${{ matrix.app }}-${{ hashFiles('**/poetry.lock') }}- | |
- uses: google-github-actions/auth@v1 | |
id: gcp | |
with: | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | |
access_token_lifetime: 600s | |
- uses: docker/login-action@v2 | |
with: | |
registry: us-central1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp.outputs.access_token }} | |
- name: Get short Git SHA | |
id: short-sha | |
run: echo "SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: us-central1-docker.pkg.dev/wafflehacks-production/application-portal/${{ matrix.app }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
type=raw,value=latest,enable={{is_default_branch}} | |
- uses: docker/build-push-action@v4 | |
with: | |
context: . | |
build-args: | | |
COMMIT_SHA=${{ steps.short-sha.outputs.SHA }} | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
target: ${{ matrix.app }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
# Temp fix for: | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move build cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-22.04 | |
needs: [containers] | |
if: github.ref == 'refs/heads/main' | |
strategy: | |
fail-fast: false | |
matrix: | |
app: | |
- api | |
- tasks | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Replace commit SHA | |
run: | | |
short_sha=$(git rev-parse --short HEAD) | |
sed -i s/SHORT_SHA/$short_sha/g ${{ matrix.app }}/fly.toml | |
- run: flyctl deploy --remote-only | |
working-directory: ${{ matrix.app }} | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }} |