diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..92c7f09 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: Build Exporter + +on: + push: + tags: ['v*'] + pull_request: + workflow_dispatch: + inputs: + push: + description: 'Push' + required: false + type: boolean + default: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: sofe + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=tag + type=ref,event=pr + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + push: ${{ inputs.push != 'false' }} # is null if trigger != workflow_dispatch + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} + platforms: linux/amd64,linux/arm64 + cache-from: | + type=gha + type=gha,scope=main + cache-to: type=gha,mode=max + provenance: false