From e0f796043cf093a8715d01ff2d4f3a89d7c25ed2 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 18 Aug 2022 10:03:06 +0200 Subject: [PATCH] Change to METALCTL_API_URL, align Github Actions workflows and updates. (#14) --- .github/workflows/docker.yaml | 55 ++++++++++++++++++++++++++ .github/workflows/latest.yaml | 34 ---------------- .github/workflows/pull_request.yaml | 40 ------------------- .github/workflows/release-drafter.yaml | 15 +++++++ .github/workflows/release.yaml | 30 -------------- Makefile | 2 +- go.mod | 2 +- go.sum | 4 +- 8 files changed, 74 insertions(+), 108 deletions(-) create mode 100644 .github/workflows/docker.yaml delete mode 100644 .github/workflows/latest.yaml delete mode 100644 .github/workflows/pull_request.yaml 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..aa95db4 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,55 @@ +--- +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@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_REGISTRY_USER }} + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go 1.19 + uses: actions/setup-go@v2 + with: + go-version: '1.19' + + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + args: --build-tags integration -p bugs -p unused --timeout=3m + + - 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: Build and push image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml deleted file mode 100644 index a92ec17..0000000 --- a/.github/workflows/latest.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build latest image - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Lint - uses: golangci/golangci-lint-action@v2 - with: - args: -p bugs -p unused --timeout=3m - - - name: Build and push Docker image - run: | - docker build -t ghcr.io/metal-stack/metal-image-cache-sync . - docker push ghcr.io/metal-stack/metal-image-cache-sync - - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml deleted file mode 100644 index 68bfe45..0000000 --- a/.github/workflows/pull_request.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build image from pull request - -on: - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - 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@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - if: steps.fork.outputs.is_fork_pr == 'false' - - - name: Lint - uses: golangci/golangci-lint-action@v2 - with: - args: -p bugs -p unused --timeout=3m - - - name: Build Docker image - run: | - docker build -t ghcr.io/metal-stack/metal-image-cache-sync:pr-${GITHUB_HEAD_REF##*/} . - - - name: Push Docker image - run: | - # pull request images are prefixed with 'pr' to prevent them from overriding released images - docker push ghcr.io/metal-stack/metal-image-cache-sync:pr-${GITHUB_HEAD_REF##*/} - 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..da232f3 --- /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@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 62dc3ab..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build image from release tag - -on: - release: - types: - - published - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Docker Login - uses: docker/login-action@v1 - with: - registry: ${{ secrets.DOCKER_REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Lint - uses: golangci/golangci-lint-action@v2 - with: - args: -p bugs -p unused --timeout=3m - - - name: Build and push Docker image - run: | - docker build -t ghcr.io/metal-stack/metal-image-cache-sync:${GITHUB_REF##*/} . - docker push ghcr.io/metal-stack/metal-image-cache-sync:${GITHUB_REF##*/} diff --git a/Makefile b/Makefile index c47bb08..77ef2a9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ MAINMODULE := github.com/metal-stack/metal-image-cache-sync/cmd COMMONDIR := $(or ${COMMONDIR},../builder) # default points to mini-lab -METAL_API_ENDPOINT := $(or ${METALCTL_URL},http://api.0.0.0.0.nip.io:8080/metal) +METAL_API_ENDPOINT := $(or ${METALCTL_API_URL},http://api.0.0.0.0.nip.io:8080/metal) METAL_API_HMAC := $(or ${METALCTL_HMAC},metal-view) include $(COMMONDIR)/Makefile.inc diff --git a/go.mod b/go.mod index fac4103..9a0b8e4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/Masterminds/semver/v3 v3.1.1 - github.com/aws/aws-sdk-go v1.44.77 + github.com/aws/aws-sdk-go v1.44.79 github.com/docker/go-units v0.4.0 github.com/go-openapi/strfmt v0.21.3 github.com/go-playground/validator/v10 v10.11.0 diff --git a/go.sum b/go.sum index de5e104..b7c441e 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/aws/aws-sdk-go v1.44.77 h1:m5rTfdv04/swD+vTuS2zn4NEwKX3yEJPMhiVCFDL/mU= -github.com/aws/aws-sdk-go v1.44.77/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go v1.44.79 h1:IZCtfBq9VlJ1Eu34I+2Y76q+XkvTtZYbEwaoVM1gzoA= +github.com/aws/aws-sdk-go v1.44.79/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=