Skip to content

Commit

Permalink
Also push images to GHCR (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
  • Loading branch information
hairyhenderson authored Jan 28, 2024
1 parent d6e44ce commit 559eb9e
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ jobs:
echo "major_version=${tag%%\.*}" >> $GITHUB_ENV
fi
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter'
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Login to DockerHub
uses: docker/login-action@v3
with:
Expand All @@ -60,17 +67,27 @@ jobs:
docker buildx imagetools create --dry-run -t localhost:5000/${IMG_NAME}:dev localhost:5000/${IMG_NAME}:latest
docker buildx imagetools create --dry-run -t localhost:5000/${IMG_NAME}:dev-alpine localhost:5000/${IMG_NAME}:alpine
if: github.repository != 'hairyhenderson/sagemcom_fast_exporter' || github.ref != 'refs/heads/main'
- name: Build & Push (main branch)
- name: Build & Push (main/tags)
run: |
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/${IMG_NAME} BUILDX_ACTION=--push
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && github.ref == 'refs/heads/main'
- name: Build & Push (tagged release)
src_repo=hairyhenderson/${IMG_NAME}
set -x
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=${src_repo} BUILDX_ACTION=--push
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && (github.ref == 'refs/heads/main' || env.is_tag == 'true')
- name: Push (tagged release)
run: |
make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=hairyhenderson/${IMG_NAME} BUILDX_ACTION=--push
src_repo=hairyhenderson/${IMG_NAME}
set -x
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${git_tag} hairyhenderson/${IMG_NAME}:latest
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${major_version} hairyhenderson/${IMG_NAME}:latest
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${git_tag}-alpine hairyhenderson/${IMG_NAME}:alpine
docker buildx imagetools create -t hairyhenderson/${IMG_NAME}:${major_version}-alpine hairyhenderson/${IMG_NAME}:alpine
repo=$src_repo
docker buildx imagetools create -t ${repo}:${git_tag} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${src_repo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${src_repo}:alpine
repo=ghcr.io/hairyhenderson/${IMG_NAME}
docker buildx imagetools create -t ${repo}:${git_tag} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${major_version} ${src_repo}:latest
docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${src_repo}:alpine
docker buildx imagetools create -t ${repo}:${major_version}-alpine ${src_repo}:alpine
if: github.repository == 'hairyhenderson/sagemcom_fast_exporter' && env.is_tag == 'true'

0 comments on commit 559eb9e

Please sign in to comment.