Skip to content

Commit

Permalink
build tag on master
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Tiwari committed Aug 5, 2023
1 parent 469f3f8 commit 037519e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ on:
- push

jobs:
preflight-job:
name: Preflight Step
build:
runs-on: ubuntu-latest

steps:
- run: env
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get Latest Tag
id: latest_tag
run: echo "::set-output name=tag::$(git describe --abbrev=0 --tags)"

- name: Display Latest Tag
run: echo "Latest tag is ${{ steps.latest_tag.outputs.tag }}"
44 changes: 41 additions & 3 deletions .github/workflows/tag-print.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,46 @@ on:
- completed

jobs:
test-job:
name: Test Step
build_master:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest

steps:
- run: env
- name: Checkout repository
uses: actions/checkout@v2

- name: Increment Tag and Create New Tag
id: increment_tag
run: |
latest_tag=${{ github.event.workflow_run.outputs.tag }}
# Extract the numeric part of the tag and increment it
tag_number=$(echo "$latest_tag" | sed 's/v//')
new_tag_number=$((tag_number + 1))
new_tag="v$new_tag_number"
git tag $new_tag
echo "::set-output name=new_tag::$new_tag"
- name: Push New Tag
run: |
new_tag=${{ steps.increment_tag.outputs.new_tag }}
git push origin $new_tag
build_other_branches:
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get the Branch name
id: tag
run: |
TAG=$(echo "${{ github.ref }}" | sed -e "s/refs\/tags\///")"
echo "::set-output name=tag::$TAG"
- name: Build and push
env:
TAG: ${{ steps.tag.outputs.TAG }}
run: |
echo "Building Docker image with tag: $TAG"

0 comments on commit 037519e

Please sign in to comment.