diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..4aa2a3dd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,68 @@ +name: Build +on: + push: + tags: + - "**" + branches: + - "**" + pull_request: + +env: + application_prefix: golang + use_cgo: 0 + +jobs: + build_container: + name: Build Container + runs-on: ubuntu-latest + strategy: + matrix: + go-version: ["1.22.x"] + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - id: setup-qemu + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64,amd64 + + - id: setup-buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Create container tags + id: container_tags + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + tags: | + type=schedule + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=branch + type=ref,event=pr + type=sha + flavor: | + latest=true + + - name: Build container + uses: docker/build-push-action@v5 + timeout-minutes: 30 + with: + context: . + platforms: linux/arm64,linux/amd64 + provenance: mode=max + push: ${{ github.event_name != 'pull_request' || github.ref_name == github.event.repository.default_branch }} + tags: ${{ steps.container_tags.outputs.tags }} + labels: ${{ steps.container_tags.outputs.labels }}