From f87e82d714373c433f9ebb9a0a4deaa34358506e Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 6 Jun 2024 14:46:32 +0200 Subject: [PATCH 1/2] Align workflow actions. --- .github/workflows/docker.yaml | 67 ++++++++++++++++++++++++++ .github/workflows/master.yml | 43 ----------------- .github/workflows/pr.yml | 53 -------------------- .github/workflows/release-drafter.yaml | 15 ++++++ .github/workflows/release.yaml | 39 --------------- 5 files changed, 82 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/docker.yaml delete mode 100644 .github/workflows/master.yml delete mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/release-drafter.yaml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..f27dea8 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,67 @@ +--- +name: Docker Build Action +on: + pull_request: + branches: + - master + release: + types: + - published + push: + branches: + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + name: Docker Build + runs-on: ubuntu-latest + + steps: + - name: Log in to the container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_REGISTRY_USER }} + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + + - name: Install libsystemd headers + run: sudo apt-get update && sudo apt-get install libsystemd-dev + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: false + + - name: Lint + uses: golangci/golangci-lint-action@v6 + with: + args: --build-tags integration -p bugs -p unused -D protogetter --timeout=5m + + - name: Make tag + run: | + [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true + + - name: Push image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} + + - name: Push image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.client + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-client:${{ env.tag }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index 78afa43..0000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Docker Image from master - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=${GITHUB_HEAD_REF##*/} - make dockerimage - make dockerpush - - - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 05585fe..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Docker Image from master - -on: - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Figure out if running fork PR - id: fork - run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"' - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - if: steps.fork.outputs.is_fork_pr == 'false' - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - # pull request images are prefixed with 'pr' to prevent them from overriding released images - export GITHUB_TAG_NAME=pr-${GITHUB_HEAD_REF##*/} - make dockerimage - make dockerpush - if: steps.fork.outputs.is_fork_pr == 'false' diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..f0e8eae --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,15 @@ +--- +name: Release Drafter Action + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index a3b78a5..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Docker Image from release tags - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install libsystemd headers - run: sudo apt-get update && sudo apt-get install libsystemd-dev - - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: "1.22" - cache: false - id: go - - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - args: -p bugs -p unused -D protogetter --timeout=3m - - - name: Docker Login - uses: docker/login-action@v3 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - name: Build the Docker images - run: | - export GITHUB_TAG_NAME=${GITHUB_REF##*/} - make dockerimage - make dockerpush \ No newline at end of file From a55d29896366180d0e732ebb960980e81f85c1f3 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 6 Jun 2024 14:50:20 +0200 Subject: [PATCH 2/2] Description. --- .github/workflows/docker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index f27dea8..e7bcaa1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -51,14 +51,14 @@ jobs: [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true - - name: Push image + - name: Push server image uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} - - name: Push image + - name: Push client image uses: docker/build-push-action@v5 with: context: .