chore(wdl): Add dockstore configuration #4
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-docker | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "v*" | |
jobs: | |
detect-changed: | |
name: Detect changed docker files | |
runs-on: ubuntu-latest | |
outputs: | |
dockers: ${{ steps.dockers-changed-matrix.outputs.dockers }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v45 | |
with: | |
separator: '\n' | |
files: | | |
docker/** | |
- name: Compile list of dockers to rebuild | |
id: dockers-changed-matrix | |
env: | |
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
run: | | |
# Build all dockers when publishing a new version tag | |
if [[ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then | |
ls -1 docker/**/Dockerfile | python3 ci/build_matrix_docker_images.py --github-output | |
else | |
python3 ci/build_matrix_docker_images.py --github-output <<<"${ALL_CHANGED_FILES}" | |
fi | |
build-dockers: | |
name: Build changed docker images | |
runs-on: ubuntu-latest | |
needs: [detect-changed] | |
strategy: | |
matrix: | |
dockers: ${{ fromJSON(needs.detect-changed.outputs.dockers) }} | |
fail-fast: false | |
# Add "id-token" with the intended permissions. | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Authenticate with GCP | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
project_id: broad-dsp-lrma | |
workload_identity_provider: projects/602335226495/locations/global/workloadIdentityPools/github/providers/pangenome-pipelines | |
service_account: ${{ vars.SERVICE_ACCOUNT }} | |
token_format: access_token | |
- name: Login to Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: us-central1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ matrix.dockers.img_name }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
type=semver,pattern=v{{major}} | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64, linux/arm64 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./${{ matrix.dockers.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 |