CD #460
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: CD | |
on: | |
push: | |
branches: | |
- "main" | |
release: | |
types: | |
- published | |
concurrency: | |
# Only run the latest workflow. | |
# If a build is already happening, cancel it to avoid a race | |
# condition where an older image overwrites a newer one. | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build [rdwatch] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# Don't fetch tags if this is a tag event. | |
# actions/checkout fails if this is true and the action | |
# triggers on a tag event. | |
fetch-tags: github.ref_type != 'tag' | |
# poetry-dynamic-versioning requires a full checkout | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate image tags | |
uses: actions/github-script@v7 | |
id: image-tags | |
with: | |
result-encoding: string | |
script: | | |
const image = 'ghcr.io/${{ github.repository }}'.toLowerCase(); | |
let tags = `${image}/rdwatch:latest`; | |
if ('${{ github.ref }}'.startsWith('refs/tags/v')) { | |
tags += `,${image}/rdwatch:${{ github.ref_name }}`; | |
} | |
return tags; | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.image-tags.outputs.result }} | |
docs: | |
name: Deploy docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# "ref" specifies the branch to check out. | |
# "github.event.release.target_commitish" is a global variable and specifies the branch the release targeted | |
ref: ${{ github.event.release.target_commitish }} | |
# Deploy docs | |
- name: Deploy docs | |
uses: mhausenblas/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CONFIG_FILE: mkdocs.yml | |
EXTRA_PACKAGES: build-base | |
REQUIREMENTS: docs/requirements.txt |