Skip to content

Commit

Permalink
Update container build, add image labels, update published tags and p…
Browse files Browse the repository at this point in the history
…revent PR's from publishing

Signed-off-by: Oscar Wieman <[email protected]>
  • Loading branch information
oscrx committed May 10, 2023
1 parent 6b38958 commit 2f9834b
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
permissions:
packages: write
on:
# Run CI when pushing to main
push:
branches: [ main ]
tags:
- 'v*'
# Run CI for PRs to main and staging
pull_request:
branches: [ main ]
Expand Down Expand Up @@ -30,38 +34,39 @@ jobs:
name: Create docker image
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/hound
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GitHub Packages
uses: docker/build-push-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
golangci:
name: lint
strategy:
Expand Down

0 comments on commit 2f9834b

Please sign in to comment.