From 545fcdbcf03c8af606ab5331b0593057e5055d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnegren?= Date: Mon, 12 Feb 2024 09:02:23 +0100 Subject: [PATCH] Cleanup packages after build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a package is not built as a result of a tag, it should be cleaned up after the tests are done. Signed-off-by: Fredrik Lönnegren --- .github/workflows/{pr.yaml => build.yaml} | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) rename .github/workflows/{pr.yaml => build.yaml} (59%) diff --git a/.github/workflows/pr.yaml b/.github/workflows/build.yaml similarity index 59% rename from .github/workflows/pr.yaml rename to .github/workflows/build.yaml index da87363909c..728a36483c8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/build.yaml @@ -1,5 +1,8 @@ -name: PR +name: Build on: + push: + tags: + - v** pull_request_target: paths: - tests/** @@ -17,6 +20,7 @@ jobs: runs-on: ubuntu-latest outputs: flavor: ${{ steps.set-matrix.outputs.flavor }} + platform: ${{ steps.set-platform.outputs.platform }} steps: - id: set-matrix run: | @@ -25,20 +29,32 @@ jobs: else echo "flavor=['green']" >> $GITHUB_OUTPUT fi + - id: set-platform + run: | + if [ "${{ startsWith(github.event.ref, 'refs/tags/v') }}" == "true" ]; then + echo "platform='linux/x86_64,linux/arm64" >> $GITHUB_OUTPUT + else + echo "platform='linux/x86_64'" >> $GITHUB_OUTPUT + fi build-toolkit: permissions: packages: write runs-on: ubuntu-latest env: - ARCH: x86_64 + PLATFORM: ${{ needs.detect.outputs.platform }} TOOLKIT_REPO: ghcr.io/${{github.repository}}/elemental-cli + outputs: + version: ${{ steps.set-version.outputs.version }} steps: - uses: actions/checkout@v4 with: ref: "${{ github.event.pull_request.merge_commit_sha }}" - run: | git fetch --prune --unshallow + - id: set-version + run: | + git describe --tags --candidates=50 >> $GITHUB_OUTPUT - name: Log in to ghcr.io uses: docker/login-action@v3 with: @@ -47,7 +63,6 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build toolkit run: | - make DOCKER_ARGS=--load build make DOCKER_ARGS=--push build build-matrix: @@ -61,3 +76,16 @@ jobs: uses: ./.github/workflows/build_and_test_x86.yaml with: flavor: ${{ matrix.flavor }} + + cleanup: + needs: + - build-toolkit + - build-matrix + steps: + - uses: actions/delete-package-versions@v4 + if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }} + with: + package-version-ids: ${{ needs.build-toolkit.outputs.version }} + owner: ${{ github.owner }} + package-name: elemental-toolkit/elemental-cli + package-type: container