Merge b297565fec
into 560cbaae74
This commit is contained in:
commit
5892a18ae0
53
.github/workflows/build.yml
vendored
53
.github/workflows/build.yml
vendored
@ -21,3 +21,56 @@ jobs:
|
|||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v ./...
|
run: go test -v ./...
|
||||||
|
|
||||||
|
push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get Image Metadata
|
||||||
|
id: image_metadata
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=ghcr.io/${{ github.event.repository.full_name }}
|
||||||
|
# Always tag latest
|
||||||
|
TAGS=$DOCKER_IMAGE:latest
|
||||||
|
# Add version tag
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
|
TAGS=$TAGS,$DOCKER_IMAGE:$VERSION
|
||||||
|
# Add major and minor tag i.e for version 1.2.3, tag 1.2 and 1
|
||||||
|
if [[ $VERSION =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then
|
||||||
|
MINOR=${VERSION%.*}
|
||||||
|
MAJOR=${MINOR%.*}
|
||||||
|
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')"
|
||||||
|
echo "::set-output name=tags::${TAGS}"
|
||||||
|
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ secrets.GHCR_USERNAME }}
|
||||||
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Build/Push To GHCR
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.image_metadata.outputs.tags }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=${{ github.event.repository.name }}
|
||||||
|
org.opencontainers.image.description=${{ github.event.repository.description }}
|
||||||
|
org.opencontainers.image.url=${{ github.event.repository.html_url }}
|
||||||
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
||||||
|
org.opencontainers.image.version=latest
|
||||||
|
org.opencontainers.image.created=${{ steps.image_metadata.outputs.date }}
|
||||||
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
|
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
|
||||||
|
Loading…
Reference in New Issue
Block a user