Skip to content

Commit

Permalink
Update GH action for pushing to GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
srisco committed Mar 16, 2021
1 parent 292197f commit bb2dd5c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/bin-downloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ jobs:
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=grycap/oscar-bin-downloader
DOCKER_HUB_IMAGE=grycap/oscar-bin-downloader
GHCR_IMAGE=ghcr.io/grycap/oscar-bin-downloader
DOCKER_PLATFORMS=linux/amd64,linux/arm64
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="--tag ${DOCKER_IMAGE}:latest"
if [[ ! -v $VERSION ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:${VERSION}"
TAGS="--tag ${DOCKER_HUB_IMAGE}:latest --tag ${GHCR_IMAGE}:latest"
if [[ ! -z "$VERSION" ]]; then
TAGS="$TAGS --tag ${DOCKER_HUB_IMAGE}:${VERSION} --tag ${GHCR_IMAGE}:${VERSION}"
fi
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
Expand All @@ -32,12 +33,18 @@ jobs:
- name: Set up Docker Buildx
uses: crazy-max/[email protected]

- name: Login
- name: Docker Hub login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin

- name: GHCR login
env:
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
run: echo "${GHCR_PASSWORD}" | docker login ghcr.io --username "${GHCR_USERNAME}" --password-stdin

- name: Build and Push
run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ jobs:
- name: Prepare docker buildx
id: prepare
run: |
DOCKER_IMAGE=grycap/oscar
DOCKER_HUB_IMAGE=grycap/oscar
GHCR_IMAGE=ghcr.io/grycap/oscar
DOCKER_PLATFORMS=linux/amd64,linux/arm64
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="--tag ${DOCKER_IMAGE}:latest"
TAGS="--tag ${DOCKER_HUB_IMAGE}:latest --tag ${GHCR_IMAGE}:latest"
if [[ ! -z "$VERSION" ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS --tag ${DOCKER_HUB_IMAGE}:${VERSION} --tag ${GHCR_IMAGE}:${VERSION}"
fi
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
Expand All @@ -45,12 +46,18 @@ jobs:
- name: Set up Docker Buildx
uses: crazy-max/[email protected]

- name: Login
- name: Docker Hub login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin

- name: GHCR login
env:
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
run: echo "${GHCR_PASSWORD}" | docker login ghcr.io --username "${GHCR_USERNAME}" --password-stdin

- name: Build and Push
run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

Expand Down

0 comments on commit bb2dd5c

Please sign in to comment.