From 1b92cd2bbca960ec84edad8e7f19ff3a8ffb38a9 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 30 Apr 2024 18:20:21 +0200 Subject: [PATCH 1/5] forks do not have permissions to push images --- .github/workflows/build-image.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 9e6d73a6..fe594328 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -15,6 +15,7 @@ env: jobs: build: name: Build + if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest strategy: fail-fast: false @@ -72,6 +73,7 @@ jobs: retention-days: 1 merge: runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name == github.repository needs: - build steps: @@ -111,4 +113,19 @@ jobs: docker buildx imagetools inspect ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} - name: Smoke Test run: | - docker run --rm -t ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} limitador-server --help \ No newline at end of file + docker run --rm -t ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} limitador-server --help + build-from-forks: + name: Build + if: github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: limitador + tags: ${{ github.sha }} + dockerfiles: | + ./Dockerfile From d0429beda441e80ac9d9cf9ec91b8fb1d5b7b3f4 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 30 Apr 2024 18:42:52 +0200 Subject: [PATCH 2/5] fixup! forks do not have permissions to push images --- .github/workflows/build-image.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index fe594328..860df488 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -15,7 +15,11 @@ env: jobs: build: name: Build - if: github.event.pull_request.head.repo.full_name == github.repository + # for tags and not forks + if: | + (startsWith(github.ref, 'refs/tags/')) || + (!startsWith(github.ref, 'refs/tags/') && + github.event.pull_request.head.repo.full_name == github.repository) runs-on: ubuntu-latest strategy: fail-fast: false @@ -73,7 +77,11 @@ jobs: retention-days: 1 merge: runs-on: ubuntu-latest - if: github.event.pull_request.head.repo.full_name == github.repository + # for tags and not forks + if: | + (startsWith(github.ref, 'refs/tags/')) || + (!startsWith(github.ref, 'refs/tags/') && + github.event.pull_request.head.repo.full_name == github.repository) needs: - build steps: @@ -115,8 +123,10 @@ jobs: run: | docker run --rm -t ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} limitador-server --help build-from-forks: - name: Build - if: github.event.pull_request.head.repo.full_name != github.repository + name: Build on forks + if: | + !startsWith(github.ref, 'refs/tags/') && + github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest steps: - name: Check out code From 41d7a7e0c04e388d8a79290715f3239d6e20b9b7 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 30 Apr 2024 18:49:12 +0200 Subject: [PATCH 3/5] dump gh context --- .github/workflows/build-image.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 860df488..2510c191 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -13,6 +13,13 @@ env: MAIN_BRANCH_NAME: main jobs: + dump: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" build: name: Build # for tags and not forks From 66679d236d703c1fbfc20d482449071f14ecb906 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 2 May 2024 10:45:35 +0200 Subject: [PATCH 4/5] gh actions: image build for forks --- .github/workflows/build-image.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 2510c191..529419da 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -22,11 +22,11 @@ jobs: run: echo "$GITHUB_CONTEXT" build: name: Build - # for tags and not forks + # for regulars pushes, tags and not forks if: | (startsWith(github.ref, 'refs/tags/')) || (!startsWith(github.ref, 'refs/tags/') && - github.event.pull_request.head.repo.full_name == github.repository) + github.event.repository.full_name == github.repository) runs-on: ubuntu-latest strategy: fail-fast: false @@ -84,11 +84,11 @@ jobs: retention-days: 1 merge: runs-on: ubuntu-latest - # for tags and not forks + # for regulars pushes, tags and not forks if: | (startsWith(github.ref, 'refs/tags/')) || (!startsWith(github.ref, 'refs/tags/') && - github.event.pull_request.head.repo.full_name == github.repository) + github.event.repository.full_name == github.repository) needs: - build steps: @@ -131,9 +131,9 @@ jobs: docker run --rm -t ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} limitador-server --help build-from-forks: name: Build on forks + # for forks if: | - !startsWith(github.ref, 'refs/tags/') && - github.event.pull_request.head.repo.full_name == github.repository + github.event.repository.full_name != github.repository) runs-on: ubuntu-latest steps: - name: Check out code @@ -146,3 +146,6 @@ jobs: tags: ${{ github.sha }} dockerfiles: | ./Dockerfile + - name: Smoke Test + run: | + docker run --rm -t limitador:${{ github.sha }} limitador-server --help From 9dc2bccc1dbda6df8d3dea87e13ab8debe3cbba7 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 2 May 2024 10:48:01 +0200 Subject: [PATCH 5/5] fixup! gh actions: image build for forks --- .github/workflows/build-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 529419da..3a0d9d72 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -133,7 +133,7 @@ jobs: name: Build on forks # for forks if: | - github.event.repository.full_name != github.repository) + github.event.repository.full_name != github.repository runs-on: ubuntu-latest steps: - name: Check out code