Skip to content

Commit

Permalink
update github workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Nov 5, 2023
1 parent ff0767c commit 5687970
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 139 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: "Scheduled: docker"
name: build/docker

on:
schedule:
- cron: '0 6 * * 1'
workflow_call:
inputs:
publish:
required: true
type: boolean

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
with:
swap-size-gb: 12

Expand All @@ -22,26 +25,28 @@ jobs:
args: --print-resources-usage

build:
name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}"
needs: lint
strategy:
fail-fast: false
matrix:
Dockerfile: [Dockerfile]
suffix: [""]
latest: ["auto"]
include: []
include:
- Dockerfile: Dockerfile
target: "final-static"
suffix: ""
latest: "auto"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
with:
swap-size-gb: 12

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }},quay.io/${{ github.repository }}
labels: |
Expand All @@ -51,30 +56,33 @@ jobs:
suffix=${{ matrix.suffix }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
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@v2
uses: docker/login-action@v3
if: ${{ inputs.publish }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
- 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: ${{ github.event_name != 'pull_request' }}
push: ${{ inputs.publish }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
44 changes: 5 additions & 39 deletions .github/workflows/ci-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
name: "CI docker"
name: "ci/docker"

on: [pull_request, workflow_dispatch]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Run Golangci lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --print-resources-usage

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
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@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build
uses: docker/build-push-action@v4
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
10 changes: 5 additions & 5 deletions .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Release: assets"
name: "release/assets"

on:
release:
Expand All @@ -8,16 +8,16 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
with:
swap-size-gb: 12

- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true

- name: Build
Expand Down
84 changes: 9 additions & 75 deletions .github/workflows/release-docker.yaml
Original file line number Diff line number Diff line change
@@ -1,83 +1,17 @@
name: "Release: docker"
name: "release/docker"

on:
push:
branches:
- '**'
- 'main'
- 'feature-**'
- 'bugfix-**'
tags:
- '*.*.*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Run Golangci lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --print-resources-usage

build:
needs: lint
strategy:
fail-fast: false
matrix:
Dockerfile: [Dockerfile]
suffix: [""]
latest: ["auto"]
include: []
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
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@v2

- name: Set up Docker Buildx2
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Quay
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./${{ matrix.Dockerfile }}
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' }}
12 changes: 12 additions & 0 deletions .github/workflows/schedule-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "schedule/docker"

on:
schedule:
- cron: '45 6 * * 1'

jobs:
schedule:
uses: ./.github/workflows/build-docker.yaml
secrets: inherit
with:
publish: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN ["./fenecon-exporter", "--help"]
#############################################
# Final
#############################################
FROM gcr.io/distroless/static
FROM gcr.io/distroless/static as final-static
ENV LOG_JSON=1
WORKDIR /
COPY --from=test /app .
Expand Down

0 comments on commit 5687970

Please sign in to comment.