From 943908784a24f02a86945ca1c214274b8a9e7973 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Wed, 27 Mar 2024 16:42:04 +0100 Subject: [PATCH] Minor changes Signed-off-by: Xabier Larrakoetxea --- .github/workflows/build-pr.yaml | 77 +++++++++++++++++++++++++ .github/workflows/ci.yaml | 2 - README.md | 2 +- scripts/build/docker/build-image-dev.sh | 5 -- scripts/build/docker/build-image.sh | 4 -- 5 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build-pr.yaml diff --git a/.github/workflows/build-pr.yaml b/.github/workflows/build-pr.yaml new file mode 100644 index 0000000..7caa467 --- /dev/null +++ b/.github/workflows/build-pr.yaml @@ -0,0 +1,77 @@ +name: Build pull request + +on: + issue_comment: + types: + - created + +jobs: + pr-release-image: + if: ${{ github.event.issue.pull_request && github.event.comment.body == '/yolo'}} + name: Release images + runs-on: ubuntu-latest + steps: + - name: Get PR SHA + id: sha + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + const pr = await github.rest.pulls.get({ + owner: context.issue.owner, + repo: context.issue.repo, + pull_number: context.issue.number, + }); + return pr.data.head.sha + + - uses: actions/checkout@v4 + with: + ref: ${{ steps.sha.outputs.result }} + + - name: React to comment + uses: actions/github-script@v7 + with: + script: | + github.rest.reactions.createForIssueComment({ + owner: context.issue.owner, + repo: context.issue.repo, + comment_id: context.payload.comment.id, + content: "rocket", + }); + + - name: Docker auth + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and publish docker images + run: make build-publish-image-all + env: + PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY} + VERSION: ${{ steps.sha.outputs.result }} + + - name: Message success + if: ${{ success() }} + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '✔ Release ready: `${{ steps.sha.outputs.result }}`', + }); + + - name: Message failure + if: ${{ failure() }} + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '❌ Release failed: `${{ steps.sha.outputs.result }}`', + }); diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0981948..583f0eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,6 @@ jobs: runs-on: ubuntu-latest container: golangci/golangci-lint:v1.56.2-alpine steps: - - run: echo "machine github.com login ${CW_GO_DEPS_LOGIN} password ${CW_GO_DEPS_TOKEN}" > ~/.netrc - uses: actions/checkout@v4 - run: | # We need this go flag because it started to error after golangci-lint is using Go 1.21. @@ -20,7 +19,6 @@ jobs: name: Unit test runs-on: ubuntu-latest steps: - - run: echo "machine github.com login ${CW_GO_DEPS_LOGIN} password ${CW_GO_DEPS_TOKEN}" > ~/.netrc - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: diff --git a/README.md b/README.md index 87b6f8c..277e0c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kube code generator -![Kubernetes release](https://img.shields.io/badge/Kubernetes-v1.<30-green?logo=Kubernetes&style=flat&color=326CE5&logoColor=white) +![Kubernetes release](https://img.shields.io/badge/Kubernetes-v1.30-green?logo=Kubernetes&style=flat&color=326CE5&logoColor=white) ## Introduction diff --git a/scripts/build/docker/build-image-dev.sh b/scripts/build/docker/build-image-dev.sh index 5ab6109..db0ef86 100755 --- a/scripts/build/docker/build-image-dev.sh +++ b/scripts/build/docker/build-image-dev.sh @@ -5,13 +5,8 @@ set -e [ -z "$VERSION" ] && echo "VERSION env var is required." && exit 1 [ -z "$IMAGE" ] && echo "IMAGE env var is required." && exit 1 [ -z "$DOCKER_FILE_PATH" ] && echo "DOCKER_FILE_PATH env var is required." && exit 1 -[ -z "$CW_GO_DEPS_LOGIN" ] && echo "CW_GO_DEPS_LOGIN env var is required (go deps)." && exit 1 -[ -z "$CW_GO_DEPS_TOKEN" ] && echo "CW_GO_DEPS_TOKEN env var is required (go deps)." && exit 1 - # Build image. echo "Building dev image ${IMAGE}:${VERSION}..." docker build \ - --build-arg CW_GO_DEPS_LOGIN="${CW_GO_DEPS_LOGIN}" \ - --build-arg CW_GO_DEPS_TOKEN="${CW_GO_DEPS_TOKEN}" \ -t "${IMAGE}:${VERSION}" \ -f "${DOCKER_FILE_PATH}" . diff --git a/scripts/build/docker/build-image.sh b/scripts/build/docker/build-image.sh index 07eb83b..3ca4913 100755 --- a/scripts/build/docker/build-image.sh +++ b/scripts/build/docker/build-image.sh @@ -5,8 +5,6 @@ set -e [ -z "$VERSION" ] && echo "VERSION env var is required." && exit 1 [ -z "$IMAGE" ] && echo "IMAGE env var is required." && exit 1 [ -z "$DOCKER_FILE_PATH" ] && echo "DOCKER_FILE_PATH env var is required." && exit 1 -[ -z "$CW_GO_DEPS_LOGIN" ] && echo "CW_GO_DEPS_LOGIN env var is required (go deps)." && exit 1 -[ -z "$CW_GO_DEPS_TOKEN" ] && echo "CW_GO_DEPS_TOKEN env var is required (go deps)." && exit 1 # By default use amd64 architecture. DEF_ARCH=amd64 @@ -17,8 +15,6 @@ IMAGE_TAG_ARCH="${IMAGE}:${VERSION}-${ARCH}" # Build image. echo "Building image ${IMAGE_TAG_ARCH}..." docker build \ - --build-arg CW_GO_DEPS_LOGIN="${CW_GO_DEPS_LOGIN}" \ - --build-arg CW_GO_DEPS_TOKEN="${CW_GO_DEPS_TOKEN}" \ --build-arg VERSION="${VERSION}" \ --build-arg ARCH="${ARCH}" \ -t "${IMAGE_TAG_ARCH}" \