langtags-deployed #249
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 and deploy | |
on: | |
push: | |
branches: [ "main", "release" ] | |
paths-ignore: | |
- kubernetes/** | |
- test/** | |
- testdata/** | |
- README.md | |
repository_dispatch: | |
types: | |
- langtags-deployed | |
- families-updated | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: ${{ (github.ref_name == 'release' || github.event_name == 'repository_dispatch' && github.event.client_payload.release) && 'production' || 'staging' }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ vars.LFF_SRC_BRANCH }} | |
# Workaround: https://github.com/docker/build-push-action/issues/461 | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
# Login against a Docker registry except on PR | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value={{date 'GGWWEHHmm'}} | |
type=raw,value=latest | |
labels: | | |
org.opencontainers.image.description=Find-a-Font REST API endpoint service | |
# Build and push Docker image with Buildx (don't push on PR) | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
sldr_zip=${{ vars.SLDR_ZIP }} | |
langtags_json=${{ vars.LANGTAGS_JSON }} | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ (github.ref_name == 'release' || github.event_name == 'repository_dispatch' && github.event.client_payload.release) && 'production' || 'staging' }} | |
url: ${{ vars.SITE_URL }} | |
steps: | |
- name: Deploy to ${{ vars.ENVIRONMENT_STAGE }} | |
uses: distributhor/workflow-webhook@v3 | |
with: | |
webhook_url: ${{ secrets.DEPLOY_WEBHOOK_URL }} | |
webhook_secret: ${{ secrets.DEPLOY_KEY }} |