Skip to content

Commit

Permalink
Merge pull request #11 from settle-finance/workflow
Browse files Browse the repository at this point in the history
Update Workflow
  • Loading branch information
sharansalian authored May 10, 2024
2 parents 8149378 + 87a7519 commit 9ae678f
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/on_merge_main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
name: "Tag on Pull Request merge"
name: Tag and Release on Main Push

on:
# Should trigger only when a Pull Request is Closed
# (the action will not create the Tag if the Pull Request is discarded - closed without merge)
pull_request:
types:
- closed
push:
branches:
- main

jobs:
TagOnPR:
name: Tag on Pull Request merge
tag-and-release:
runs-on: ubuntu-latest
# This 'if' condition is important for ensuring the workflow only runs for merged PRs
# (avoid running when a PR is discarded - closed without merging)
if: github.event.pull_request.merged == true

steps:
- name: Tag on PR merge
id: tag-on-pr-merge
uses: David-Lor/action-tag-on-pr-merge@main
with:
push-tag: true
- name: Print fetched tag
run: echo "${{ steps.tag-on-pr-merge.outputs.tag }}"
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
- name: Get commit SHA
id: commit_sha
run: echo "${GITHUB_SHA::8}" # Extracts the first 8 characters of the commit SHA

- name: Create Tag and Release
run: |
git tag -a "v${{ steps.commit_sha.outputs.stdout }}" -m "Automated tag creation on main push"
git push origin "v${{ steps.commit_sha.outputs.stdout }}"
hub release create -m "Release v${{ steps.commit_sha.outputs.stdout }}" "v${{ steps.commit_sha.outputs.stdout }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9ae678f

Please sign in to comment.