|
| 1 | +name: build/docker |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + publish: |
| 7 | + required: true |
| 8 | + type: boolean |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set Swap Space |
| 17 | + uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c |
| 18 | + with: |
| 19 | + swap-size-gb: 12 |
| 20 | + |
| 21 | + - uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version-file: 'go.mod' |
| 24 | + cache-dependency-path: "go.sum" |
| 25 | + check-latest: true |
| 26 | + |
| 27 | + - name: Run Golangci lint |
| 28 | + uses: golangci/golangci-lint-action@v4 |
| 29 | + with: |
| 30 | + version: latest |
| 31 | + args: --print-resources-usage |
| 32 | + |
| 33 | + build: |
| 34 | + name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" |
| 35 | + needs: lint |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + include: |
| 40 | + - Dockerfile: Dockerfile |
| 41 | + target: "final-static" |
| 42 | + suffix: "" |
| 43 | + latest: "auto" |
| 44 | + |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set Swap Space |
| 50 | + uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c |
| 51 | + with: |
| 52 | + swap-size-gb: 12 |
| 53 | + |
| 54 | + - uses: actions/setup-go@v5 |
| 55 | + with: |
| 56 | + go-version-file: 'go.mod' |
| 57 | + cache-dependency-path: "go.sum" |
| 58 | + check-latest: true |
| 59 | + |
| 60 | + - name: Docker meta |
| 61 | + id: docker_meta |
| 62 | + uses: docker/metadata-action@v5 |
| 63 | + with: |
| 64 | + images: | |
| 65 | + ${{ github.repository }} |
| 66 | + quay.io/${{ github.repository }} |
| 67 | + labels: | |
| 68 | + io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md |
| 69 | + flavor: | |
| 70 | + latest=${{ matrix.latest }} |
| 71 | + suffix=${{ matrix.suffix }} |
| 72 | +
|
| 73 | + - name: Set up QEMU |
| 74 | + uses: docker/setup-qemu-action@v3 |
| 75 | + |
| 76 | + - name: Set up Docker Buildx |
| 77 | + uses: docker/setup-buildx-action@v3 |
| 78 | + |
| 79 | + - name: Login to DockerHub |
| 80 | + uses: docker/login-action@v3 |
| 81 | + if: ${{ inputs.publish }} |
| 82 | + with: |
| 83 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 84 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Login to Quay |
| 87 | + uses: docker/login-action@v3 |
| 88 | + if: ${{ inputs.publish }} |
| 89 | + with: |
| 90 | + registry: quay.io |
| 91 | + username: ${{ secrets.QUAY_USERNAME }} |
| 92 | + password: ${{ secrets.QUAY_TOKEN }} |
| 93 | + |
| 94 | + - name: ${{ inputs.publish && 'Build and push' || 'Build' }} |
| 95 | + uses: docker/build-push-action@v5 |
| 96 | + with: |
| 97 | + context: . |
| 98 | + file: ./${{ matrix.Dockerfile }} |
| 99 | + target: ${{ matrix.target }} |
| 100 | + platforms: linux/amd64,linux/arm64 |
| 101 | + push: ${{ inputs.publish }} |
| 102 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 103 | + labels: ${{ steps.docker_meta.outputs.labels }} |
0 commit comments