Merge pull request #144 from hibare/dependabot/go_modules/golang.org/… #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Build & Publish | |
on: | |
push: | |
tags: | |
- "v*" | |
branches: | |
- main | |
pull_request: | |
branches: | |
- "main" | |
- "dev" | |
paths-ignore: | |
- "**/README.md" | |
- "**/Makefile" | |
- "**/.env.**" | |
- "**/docker-compose.*.yml" | |
- "**/.vscode" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
docker-image-test-publish: | |
# Trigger on pull request, push to main and tag creation | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write # For cosign | |
packages: write # For GHCR | |
steps: | |
- name: Set Metadata | |
id: set-metadata | |
run: | | |
DOCKER_TAGS="unknown" | |
VERSION="unknown" | |
IMAGE_NAMES="hibare/gopg2s3dump ghcr.io/hibare/gopg2s3dump" | |
if [ "${{ github.event_name }}" == "push" ]; then | |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
DOCKER_TAGS="next" | |
VERSION="next" | |
elif [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then | |
DOCKER_TAGS="type=semver,pattern={{version}} type=semver,pattern={{major}}" | |
VERSION="${GITHUB_REF#refs/tags/v}" | |
else | |
echo "Unknown ref: ${{ github.ref }}" | |
exit 1 | |
fi | |
elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
DOCKER_TAGS="test" | |
VERSION="test" | |
else | |
echo "Unknown event: ${{ github.event_name }}" | |
exit 1 | |
fi | |
echo "docker_image_names=$IMAGE_NAMES" >> $GITHUB_OUTPUT | |
echo "docker_tags=$DOCKER_TAGS" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: image-build-publish | |
uses: hibare/.github/github/shared-workflows/docker-image-build-publish@0962b9d76360405b3c4bf78f91424b7905bb03a8 # v0.3.0 | |
with: | |
image_names: ${{ steps.set-metadata.outputs.docker_image_names }} | |
tags: ${{ steps.set-metadata.outputs.docker_tags }} | |
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64 | |
push_dockerhub: ${{ github.event_name != 'pull_request' }} | |
push_ghcr: ${{ github.event_name != 'pull_request' }} | |
build_args: VERSION=${{ steps.set-metadata.outputs.version }} | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |