-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Knut Ahlers <[email protected]>
- Loading branch information
Showing
6 changed files
with
79 additions
and
4 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
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,36 @@ | ||
--- | ||
|
||
name: docker-publish | ||
on: | ||
push: | ||
branches: ['master'] | ||
tags: ['v*'] | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
docker-publish: | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
show-progress: false | ||
|
||
- name: Log into registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker Build & Publish | ||
run: bash ci/docker-publish.sh | ||
|
||
... |
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ FROM alpine:latest | |
|
||
LABEL org.opencontainers.image.authors='Knut Ahlers <[email protected]>' \ | ||
org.opencontainers.image.version='1.12.0' \ | ||
org.opencontainers.image.url='https://hub.docker.com/r/luzifer/ots/' \ | ||
org.opencontainers.image.url='https://github.com/Luzifer/ots/pkgs/container/ots' \ | ||
org.opencontainers.image.documentation='https://github.com/Luzifer/ots/wiki' \ | ||
org.opencontainers.image.source='https://github.com/Luzifer/ots' \ | ||
org.opencontainers.image.licenses='Apache-2.0' | ||
|
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ FROM scratch | |
|
||
LABEL org.opencontainers.image.authors='Knut Ahlers <[email protected]>' \ | ||
org.opencontainers.image.version='1.12.0' \ | ||
org.opencontainers.image.url='https://hub.docker.com/r/luzifer/ots/' \ | ||
org.opencontainers.image.url='https://github.com/Luzifer/ots/pkgs/container/ots' \ | ||
org.opencontainers.image.documentation='https://github.com/Luzifer/ots/wiki' \ | ||
org.opencontainers.image.source='https://github.com/Luzifer/ots' \ | ||
org.opencontainers.image.licenses='Apache-2.0' | ||
|
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
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,40 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
function log() { | ||
echo "[$(date +%H:%M:%S)] $@" >&2 | ||
} | ||
|
||
[[ -n $GITHUB_REF_NAME ]] || { | ||
log "ERR: This script is intended to run on a Github Action only." | ||
exit 1 | ||
} | ||
|
||
repo="ghcr.io/${GITHUB_REPOSITORY,,}" | ||
tags=() | ||
|
||
case "${GITHUB_REF_TYPE}" in | ||
branch) | ||
# Generic build to develop: Workflow has to limit branches to master | ||
tags+=(develop) | ||
;; | ||
tag) | ||
# Build to latest & tag: Older tags are not intended to rebuild | ||
tags+=(latest ${GITHUB_REF_NAME}) | ||
;; | ||
*) | ||
log "ERR: The ref type ${GITHUB_REF_TYPE} is not handled." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
log "Building Docker image..." | ||
docker build -t "${repo}:local" . | ||
|
||
for ref in "${tags[@]}"; do | ||
log "Pushing Docker image to '${repo}:${ref}'..." | ||
docker tag "${repo}:local" "${repo}:${ref}" | ||
docker push "${repo}:${ref}" | ||
done | ||
|
||
log "Publish finished." |