Trying workflow #264
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: Test, Build and Push to Artifact Registry | ||
on: | ||
push: | ||
env: | ||
IMAGE_NAME: europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image | ||
jobs: | ||
build-activitypub: | ||
environment: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image | ||
tags: | | ||
type=edge,branch=main | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha,priority=1100 | ||
- name: "Build docker image" | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: "{{defaultContext}}" | ||
load: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
test-activitypub: | ||
needs: build-activitypub | ||
environment: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Create ci docker compose file" | ||
run: | | ||
echo " | ||
services: | ||
activitypub: | ||
image: $IMAGE_NAME:$DOCKER_METADATA_OUTPUT_VERSION" > docker-compose.ci.yml | ||
- name: "Run tests" | ||
run: yarn test:all | ||
build-migrations: | ||
environment: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
europe-west4-docker.pkg.dev/ghost-activitypub/main/migrations | ||
tags: | | ||
type=edge,branch=main | ||
- name: "Build docker image" | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: migrate | ||
load: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
deploy-migrations: | ||
needs: [test-activitypub, build-migrations] | ||
environment: build | ||
runs-on: ubuntu-latest | ||
- name: Login to GAR | ||
run: echo Login to GAR | ||
deploy-activitypub: | ||
needs: [test-activitypub, deploy-migrations] # Ensure the app deploys after the migration and tests | ||
environment: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Login to GAR" | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: europe-west4-docker.pkg.dev | ||
username: _json_key | ||
password: ${{ secrets.SERVICE_ACCOUNT_KEY }} | ||
- name: "Auth with gcloud" | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }} | ||
- name: "Deploy to Cloud Run" | ||
uses: 'google-github-actions/deploy-cloudrun@v2' | ||
with: | ||
image: europe-west4-docker.pkg.dev/ghost-activitypub/main/test-image:edge | ||
region: europe-west4 | ||
service: activitypub |