Skip to content

update ghcr login step for automatic builds #111

update ghcr login step for automatic builds

update ghcr login step for automatic builds #111

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
- name: Check out the repo
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/${{ github.repository }}
VERSION=latest
if [[ '${{ github.head_ref }}' != '' ]]; then
VERSION=${{github.head_ref}}
fi
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${{ steps.date.outputs.date }}"
echo ${TAGS}
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
- name: Prepare-multiarch
id: prep-multiarch
run: |
DOCKER_IMAGE=ghcr.io/${{ github.repository }}
VERSION=latest
if [[ '${{ github.head_ref }}' != '' ]]; then
VERSION=${{github.head_ref}}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}-multiarch,${DOCKER_IMAGE}:${{ steps.date.outputs.date }}-multiarch"
echo ${TAGS}
echo "tags-multiarch=${TAGS}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GitHub Packages
uses: docker/build-push-action@v2
with:
context: .
file: ./.docker/Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}
- name: Push multiarch to GitHub Packages
uses: docker/build-push-action@v2
with:
context: .
file: ./.docker/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ${{ steps.prep-multiarch.outputs.tags-multiarch }}