Skip to content

update for latest GHS #101

update for latest GHS

update for latest GHS #101

name: "Publish Docker Image"
on:
workflow_dispatch:
push:
tags:
- "v*"
env:
SLUG_DOCKERHUB: ${{ secrets.DOCKER_USERNAME }}/ghs-server
SLUG_GHCR: ${{ github.repository_owner }}/ghs-server
jobs:
build-and-publish-docker-image:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
-
name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.SLUG_DOCKERHUB }}
ghcr.io/${{ env.SLUG_GHCR }}
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} # automatic: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Inspect Image published to Docker
run: |
docker pull "${{ env.SLUG_DOCKERHUB }}:${{ steps.meta.outputs.version }}"
docker image inspect "${{ env.SLUG_DOCKERHUB }}:${{ steps.meta.outputs.version }}"
-
name: Lowercase GHCR repository name # required because docker doesn't support uppercase chars: https://github.com/docker/build-push-action/issues/37
run: |
echo "SLUG_GHCR_LC=${SLUG_GHCR,,}" >>${GITHUB_ENV}
-
name: Inspect Image published to GHCR
run: |
docker pull "ghcr.io/${{ env.SLUG_GHCR_LC }}:${{ steps.meta.outputs.version }}"
docker image inspect "ghcr.io/${{ env.SLUG_GHCR_LC }}:${{ steps.meta.outputs.version }}"