From 4cafbd7a0a57f95dca49826b6999ae1ac22e2b2e Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 3 Nov 2024 15:55:03 +0100 Subject: [PATCH] CI: build container when the version is a clean git tag --- .forgejo/workflows/build.yaml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index a562f4f..28402a4 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -13,6 +13,8 @@ jobs: runs-on: container steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: pnpm/action-setup@v4 name: Install pnpm @@ -31,17 +33,22 @@ jobs: - name: Build package (transpile ts => js) run: ng build - - name: Git unshallow - get all history from Git to get the tag for the computation of the version - if: ${{ inputs.build }} - run: git pull --unshallow + #- name: Git unshallow - get all history from Git to get the tag for the computation of the version + # if: ${{ inputs.build }} + # run: git pull --unshallow - name: Get the version from git - if: ${{ inputs.build }} id: version run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT + - name: Check if the container should be built + id: builder + env: + builder: ${{ inputs.build || !contains(steps.version.output.version, '-') }} + run: echo $builder + - name: Build container - if: ${{ inputs.build }} + if: ${{ steps.builder.builder }} uses: actions/buildah-build@v1 with: image: treetrail-frontend @@ -50,13 +57,13 @@ jobs: ./Containerfile - name: Workaround for bug of podman-login - if: ${{ inputs.build }} + if: ${{ steps.builder.builder }} run: | mkdir -p $HOME/.docker echo "{ \"auths\": {} }" > $HOME/.docker/config.json - name: Log in to container registry (with another workaround) - if: ${{ inputs.build }} + if: ${{ steps.builder.builder }} uses: actions/podman-login@v1 with: registry: ${{ vars.REGISTRY }} @@ -65,7 +72,7 @@ jobs: auth_file_path: /tmp/auth.json - uses: actions/push-to-registry@v2 - if: ${{ inputs.build }} + if: ${{ steps.builder.builder }} with: registry: "docker://${{ vars.REGISTRY }}" image: treetrail-frontend