forked from getodk/central
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Docker images in GitHub Actions
Co-authored-by: Matthias Brandt <[email protected]>
- Loading branch information
1 parent
774b491
commit a0a3238
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: [next, master] | ||
# Publish semver tags as releases. | ||
tags: ["v*.*.*"] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
REGISTRY_WITH_PATH: ghcr.io/${{ github.repository_owner }} | ||
|
||
jobs: | ||
build-push-image: | ||
strategy: | ||
matrix: | ||
image: [secrets, nginx, service, enketo] | ||
build_args: [""] | ||
flavor: [""] | ||
include: | ||
# Build additional OIDC flavor for nginx (tags will be suffixed with -oidc) | ||
- image: nginx | ||
flavor: | | ||
latest=true | ||
suffix=-oidc,onlatest=true | ||
build_args: | | ||
OIDC_ENABLED=true | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
- 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 }} | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY_WITH_PATH }}/central-${{ matrix.image }} | ||
flavor: ${{ matrix.flavor }} | ||
# Generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}}.{{hotfix}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- name: Build and push ${{ matrix.image }} Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ${{ matrix.image }}.dockerfile | ||
context: . | ||
build-args: ${{ matrix.build_args }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |