From 4f8c764fbeaf31c94fa5258c6b8318c34df2098c Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 3 Nov 2024 16:19:52 +0100 Subject: [PATCH] CI: build container when the version is a clean git tag 3 --- .forgejo/workflows/build.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 738bfe3..e7d6566 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -16,6 +16,17 @@ jobs: with: fetch-depth: 0 + - name: Get the version from git + id: version + run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT + + - name: Check if the container should be built + id: builder + run: echo "run=toJSON(${{ inputs.build || !contains(steps.version.output.version, '-')) }}" >> $GITHUB_OUTPUT + + - name: Check + run: echo "Build? fromJSON(${{ steps.builder.output.run }})" + - uses: pnpm/action-setup@v4 name: Install pnpm with: @@ -37,19 +48,8 @@ jobs: # if: ${{ inputs.build }} # run: git pull --unshallow - - name: Get the version from git - id: version - run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT - - - name: Check if the container should be built - id: builder - run: echo "run=${{ inputs.build || !contains(steps.version.output.version, '-') }}" >> $GITHUB_OUTPUT - - - name: Check - run: echo "Build? ${{ steps.builder.output.run }}" - - name: Build container - if: ${{ steps.builder.output.run }} + if: fromJSON(steps.builder.output.run) uses: actions/buildah-build@v1 with: image: treetrail-frontend @@ -60,13 +60,13 @@ jobs: ./Containerfile - name: Workaround for bug of podman-login - if: ${{ steps.builder.output.run }} + if: fromJSON(steps.builder.output.run) run: | mkdir -p $HOME/.docker echo "{ \"auths\": {} }" > $HOME/.docker/config.json - name: Log in to container registry (with another workaround) - if: ${{ steps.builder.output.run }} + if: fromJSON(steps.builder.output.run) uses: actions/podman-login@v1 with: registry: ${{ vars.REGISTRY }} @@ -75,7 +75,7 @@ jobs: auth_file_path: /tmp/auth.json - uses: actions/push-to-registry@v2 - if: ${{ steps.builder.output.run }} + if: fromJSON(steps.builder.output.run) with: registry: "docker://${{ vars.REGISTRY }}" image: treetrail-frontend