From 0c72a7a5b4da02811e490ce3d36db311acfec014 Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Sat, 17 Feb 2024 16:55:18 +0100 Subject: [PATCH] update workflows Signed-off-by: Markus Blaschke --- .github/workflows/build-docker.yaml | 101 +++++++++++++++++++++++++ .github/workflows/ci-docker.yaml | 42 +--------- .github/workflows/release-assets.yaml | 5 +- .github/workflows/release-docker.yaml | 82 ++------------------ .github/workflows/schedule-docker.yaml | 84 ++------------------ 5 files changed, 119 insertions(+), 195 deletions(-) create mode 100644 .github/workflows/build-docker.yaml diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml new file mode 100644 index 0000000..8ac7451 --- /dev/null +++ b/.github/workflows/build-docker.yaml @@ -0,0 +1,101 @@ +name: build/docker + +on: + workflow_call: + inputs: + publish: + required: true + type: boolean + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set Swap Space + uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c + with: + swap-size-gb: 12 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache-dependency-path: "go.sum" + check-latest: true + + - name: Run Golangci lint + uses: golangci/golangci-lint-action@v4 + with: + version: latest + args: --print-resources-usage + + build: + name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" + needs: lint + strategy: + fail-fast: false + matrix: + include: + - Dockerfile: Dockerfile + target: "final-static" + suffix: "" + latest: "auto" + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set Swap Space + uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c + with: + swap-size-gb: 12 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache-dependency-path: "go.sum" + check-latest: true + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }},quay.io/${{ github.repository }} + labels: | + io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md + flavor: | + latest=${{ matrix.latest }} + suffix=${{ matrix.suffix }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + if: ${{ inputs.publish }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to Quay + uses: docker/login-action@v3 + if: ${{ inputs.publish }} + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: ${{ inputs.publish && 'Build and push' || 'Build' }} + uses: docker/build-push-action@v5 + with: + context: . + file: ./${{ matrix.Dockerfile }} + target: ${{ matrix.target }} + platforms: linux/amd64,linux/arm64 + push: ${{ inputs.publish }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/.github/workflows/ci-docker.yaml b/.github/workflows/ci-docker.yaml index 7ef10c8..423010f 100644 --- a/.github/workflows/ci-docker.yaml +++ b/.github/workflows/ci-docker.yaml @@ -4,41 +4,7 @@ on: [pull_request, workflow_dispatch] jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c - with: - swap-size-gb: 12 - - - name: Run Golangci lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --print-resources-usage - - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ github.repository }},quay.io/${{ github.repository }} - labels: | - io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - push: false - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + uses: ./.github/workflows/build-docker.yaml + secrets: inherit + with: + publish: false diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml index fc8f9e6..03ec06e 100644 --- a/.github/workflows/release-assets.yaml +++ b/.github/workflows/release-assets.yaml @@ -15,9 +15,10 @@ jobs: with: swap-size-gb: 12 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version-file: 'go.mod' + cache-dependency-path: "go.sum" check-latest: true - name: Build diff --git a/.github/workflows/release-docker.yaml b/.github/workflows/release-docker.yaml index aad6404..90186ea 100644 --- a/.github/workflows/release-docker.yaml +++ b/.github/workflows/release-docker.yaml @@ -10,80 +10,8 @@ on: - '*.*.*' jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c - with: - swap-size-gb: 12 - - - name: Run Golangci lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --print-resources-usage - - build: - name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" - needs: lint - strategy: - fail-fast: false - matrix: - include: - - - Dockerfile: Dockerfile - target: "final-static" - suffix: "" - latest: "auto" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c - with: - swap-size-gb: 12 - - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ github.repository }},quay.io/${{ github.repository }} - labels: | - io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md - flavor: | - latest=${{ matrix.latest }} - suffix=${{ matrix.suffix }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker 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: Login to Quay - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ./${{ matrix.Dockerfile }} - target: ${{ matrix.target }} - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + release: + uses: ./.github/workflows/build-docker.yaml + secrets: inherit + with: + publish: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/schedule-docker.yaml b/.github/workflows/schedule-docker.yaml index e86918c..8b58d51 100644 --- a/.github/workflows/schedule-docker.yaml +++ b/.github/workflows/schedule-docker.yaml @@ -2,83 +2,11 @@ name: "schedule/docker" on: schedule: - - cron: '0 6 * * 1' + - cron: '45 6 * * 1' jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c - with: - swap-size-gb: 12 - - - name: Run Golangci lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --print-resources-usage - - build: - name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}" - needs: lint - strategy: - fail-fast: false - matrix: - include: - - - Dockerfile: Dockerfile - target: "final-static" - suffix: "" - latest: "auto" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c - with: - swap-size-gb: 12 - - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ${{ github.repository }},quay.io/${{ github.repository }} - labels: | - io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md - flavor: | - latest=${{ matrix.latest }} - suffix=${{ matrix.suffix }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker 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: Login to Quay - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ./${{ matrix.Dockerfile }} - target: ${{ matrix.target }} - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + schedule: + uses: ./.github/workflows/build-docker.yaml + secrets: inherit + with: + publish: true