From 86d3c1932dfe24c5380320e9dde053103d3cb29c Mon Sep 17 00:00:00 2001 From: Moritz Kirmse <61978301+mki-c2c@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:17:44 +0200 Subject: [PATCH] Fine-tune workflow for tag generation on main branch pushes (#141) * output all test variables * fix workflow * fix workflow * pretty print objects * fix echo quoting * fix quotes * test tags * clean workflow * create auto tag on branch pushes instead of PR * debug bash * test mutli cmd run * do use env variable * cleanup * verbose output * fix echo * fix bash * another bash check * unecho * echo variants * more echos * checkout * check git version * deepen fetch to find parents * cleanup * set correct tag names and job activation conditions --- .github/workflows/ci_bundle.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci_bundle.yml b/.github/workflows/ci_bundle.yml index d8e24243..786ff32d 100644 --- a/.github/workflows/ci_bundle.yml +++ b/.github/workflows/ci_bundle.yml @@ -1,28 +1,31 @@ name: CI_package on: - pull_request: - types: - - closed - branches: - - main push: + branches: + - 'main' tags: - '*' jobs: tag-version: - if: github.event_name == 'pull_request' + if: github.ref_type != 'tag' runs-on: ubuntu-latest steps: - name: checkout ${{ github.head_ref }} uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} - fetch-depth: 0 - - run: git status - - run: git rev-parse --abbrev-ref HEAD + # default depth is 1, but we need the parent refs + fetch-depth: 2 + - name: compute tag name + shell: bash + run: | + branch=$([[ $(git log --pretty="%p" -n 1 | wc -w) -gt 1 ]] \ + && echo $(git log -n 1 --pretty="%s" | sed "s|.*Geoportail-Luxembourg/\(.*\)|\1|") \ + || git branch --show-current) + echo $branch + echo "AUTO_TAG=${branch}_CI_$(git log -n 1 --pretty=%h)" >> $GITHUB_ENV - name: tag ${{ github.head_ref }} run: | - git tag $(git rev-parse --abbrev-ref HEAD)_CI_$(git rev-parse --short HEAD) + git tag ${{ env.AUTO_TAG }} git push --tags lux-package: # the combination (if always) + (needs tag-version) makes sure the lux-package job runs