From f6464db418be3d98ddf6337ca86836d524ae435e Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Mon, 21 Jul 2025 15:59:41 +0200 Subject: [PATCH] add validate step --- .gitea/workflows/varnish-exporter.yml | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/varnish-exporter.yml b/.gitea/workflows/varnish-exporter.yml index 46bc1ea..2b6d013 100644 --- a/.gitea/workflows/varnish-exporter.yml +++ b/.gitea/workflows/varnish-exporter.yml @@ -8,30 +8,38 @@ on: - '*' jobs: - build: + validate: runs-on: ubuntu-latest + outputs: + status: ${{ steps.new_version.outputs.status }} steps: - - uses: actions/checkout@v4 # default goes to /workspace/Clients/xxx + - uses: actions/checkout@v4 - - name: test - add env file + - name: Get latest release version + id: new_version run: | - echo "MY_GLOBAL_VAR=newvalue" > .version - #git config --global user.name 'gitea-actions' - #git config --global user.email 'no-reply@brainsys.io' - #git add .version - #git commit -m "Update version variable" - #git push + CURRENT=`cat .version` + LATEST=`curl --silent https://api.github.com/repos/jonnenauha/prometheus_varnish_exporter/releases/latest | jq -r .tag_name | sed "s/v//"` + if [[ $LATEST -gt $CURRENT ]]; then echo $LATEST > .version; echo "status=build" >> $GITEA_OUTPUT; done - uses: stefanzweifel/git-auto-commit-action@v6 with: branch: main - commit_message: gitea-actions auto commit + file_pattern: '.version' + commit_user_name: gitea-actions[bot] + commit_user_email: no-replay@brainsys.io + commit_message: gitea-actions auto commit - update version push_options: '--force' + build: + if: steps.validate.output.status == build + runs-on: ubuntu-latest + needs: validate + steps: + - uses: actions/checkout@v4 + - name: Get version - run: | - TAG=${{ gitea.ref_name }} - echo "VERSION=${TAG#v}" | tee -a $GITEA_ENV + run: VERSION=`cat .version` - name: Setup go uses: actions/setup-go@v4