ci: resolve changes workflow for pull requests #53
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: docker | |
"on": | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- platform: linux/386 | |
goos: linux | |
goarch: 386 | |
tags: netgo | |
- platform: linux/amd64 | |
goos: linux | |
goarch: amd64 | |
tags: netgo | |
- platform: linux/arm/6 | |
goos: linux | |
goarch: arm | |
goarm: 6 | |
tags: netgo | |
- platform: linux/arm64 | |
goos: linux | |
goarch: arm64 | |
tags: netgo | |
steps: | |
- name: Checkout source | |
id: source | |
uses: actions/checkout@v4 | |
- name: Setup golang | |
id: golang | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ^1.21.0 | |
- name: Run generate | |
id: generate | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GOARM: ${{ matrix.goarm }} | |
TAGS: ${{ matrix.tags }} | |
run: make generate | |
- name: Run build | |
id: build | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GOARM: ${{ matrix.goarm }} | |
TAGS: ${{ matrix.tags }} | |
run: make build | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
promhippie/scw-exporter | |
quay.io/promhippie/scw-exporter | |
ghcr.io/promhippie/scw-exporter | |
labels: | | |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/promhippie/scw_exporter/master/README.md | |
org.opencontainers.image.vendor=Webhippie | |
maintainer=Thomas Boerger <[email protected]> | |
tags: | | |
type=ref,event=pr | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
flavor: | | |
suffix=-${{ matrix.goos }}-${{ matrix.goarch }} | |
- name: Setup qemu | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Hub login | |
id: login1 | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Quay login | |
id: login2 | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Ghcr login | |
id: login3 | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: bothippie | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build image | |
id: publish | |
uses: docker/build-push-action@v5 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: . | |
provenance: false | |
file: docker/Dockerfile.${{ matrix.goos }}.${{ matrix.goarch }} | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
manifest: | |
runs-on: ubuntu-latest | |
needs: docker | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout source | |
id: source | |
uses: actions/checkout@v4 | |
- name: Hub tags | |
id: hubTags | |
uses: docker/metadata-action@v5 | |
with: | |
images: promhippie/scw-exporter | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Hub manifest | |
id: hub | |
uses: actionhippie/manifest@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v6 | |
template: promhippie/scw-exporter:VERSION-OS-ARCH | |
target: ${{ steps.hubTags.outputs.tags }} | |
ignore_missing: true | |
- name: Quay tags | |
id: quayTags | |
uses: docker/metadata-action@v5 | |
with: | |
images: quay.io/promhippie/scw-exporter | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Quay manifest | |
id: quay | |
if: github.event_name != 'pull_request' | |
uses: actionhippie/manifest@v1 | |
with: | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v6 | |
template: quay.io/promhippie/scw-exporter:VERSION-OS-ARCH | |
target: ${{ steps.quayTags.outputs.tags }} | |
ignore_missing: true | |
- name: Ghcr tags | |
id: ghcrTags | |
if: github.event_name != 'pull_request' | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/promhippie/scw-exporter | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Ghcr manifest | |
id: ghcr | |
if: github.event_name != 'pull_request' | |
uses: actionhippie/manifest@v1 | |
with: | |
username: bothippie | |
password: ${{ secrets.GITHUB_TOKEN }} | |
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v6 | |
template: ghcr.io/promhippie/scw-exporter:VERSION-OS-ARCH | |
target: ${{ steps.ghcrTags.outputs.tags }} | |
ignore_missing: true | |
readme: | |
runs-on: ubuntu-latest | |
needs: docker | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout source | |
id: source | |
uses: actions/checkout@v4 | |
- name: Hub readme | |
id: hub | |
if: github.event_name != 'pull_request' | |
uses: actionhippie/pushrm@v1 | |
with: | |
provider: dockerhub | |
target: promhippie/scw-exporter | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
description: Scaleway Exporter | |
readme: README.md | |
- name: Quay readme | |
id: quay | |
if: github.event_name != 'pull_request' | |
uses: actionhippie/pushrm@v1 | |
with: | |
provider: quay | |
target: quay.io/promhippie/scw-exporter | |
apikey: ${{ secrets.QUAY_APIKEY }} | |
readme: README.md | |
... |