generated from fmartingr/golang-app-template
41 lines
1.0 KiB
YAML
41 lines
1.0 KiB
YAML
|
name: "Build Docker"
|
||
|
|
||
|
on:
|
||
|
workflow_call:
|
||
|
workflow_dispatch:
|
||
|
|
||
|
jobs:
|
||
|
buildx:
|
||
|
runs-on: ubuntu-latest
|
||
|
permissions:
|
||
|
contents: read # Required to read dist files (and repository)
|
||
|
packages: write # Required to push packages to GHCR
|
||
|
env:
|
||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
|
name: Build Docker
|
||
|
steps:
|
||
|
- uses: actions/checkout@v2
|
||
|
with:
|
||
|
fetch-depth: 0
|
||
|
|
||
|
- uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
name: dist
|
||
|
path: dist
|
||
|
|
||
|
- name: Log in to registry
|
||
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
|
||
|
|
||
|
- name: Buildx
|
||
|
run: |
|
||
|
REPOSITORY=ghcr.io/${{ github.repository }}
|
||
|
|
||
|
TAG_COMMIT=$(git describe --tag)
|
||
|
TAG_MAIN=latest
|
||
|
if [ -z "$(git tag --points-at HEAD)" ]
|
||
|
then
|
||
|
TAG_MAIN="dev"
|
||
|
fi
|
||
|
|
||
|
CONTAINER_BUILDX_OPTIONS="--push --output=type=registry --tag $REPOSITORY:$TAG_COMMIT --tag $REPOSITORY:$TAG_MAIN" make buildx
|