From 30e74bd33941f6dc001a96e7746f10340dfeb50c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Sun, 4 Feb 2024 14:57:44 -0700 Subject: [PATCH] Add a github action that automatically create tag on master. This action will add a tag matching ROUTEROS release once master pass the CI step after a push to master (can be the result of direct push, PR merge, ...). This tag being pushed will trigger the CD github action which will push the docker image that match this tag to docker hub. --- .github/workflows/tag.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..86650d0 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,36 @@ +name: "Tag master with new version of RouterOS when CI pass" + +on: + push: + branches: + - "master" + +permissions: + contents: write + pull-requests: read + +jobs: + call_test: + uses: EvilFreelancer/docker-routeros/.github/workflows/ci.yml@master + + tag: + name: "Add a tag to git" + runs-on: "ubuntu-latest" + needs: call_test + if: always() && needs.call_test.result == 'success' + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: '0' + + - name: Add new tag on git + run: | + NEW_TAG=$(grep 'ROUTEROS_VERSION="' Dockerfile |cut -d '"' -f 2) + git config user.name 'GitHub Actions' + git config user.email 'github-actions@users.noreply.github.com' + git tag "$NEW_TAG" + + - name: Push new tag to git + if: ${{ !env.ACT }} + run: git push origin "$NEW_TAG"