Can we use GitHub actions in order to get the GitHub release tag and use it in the repo code for version?

35 Views Asked by At

Attempted to use the below code to cause the GitHub actions to start when the release tag is published, but it isn't working.

name: Update Values on Release

on:
  release:
    types: [ published ]  # Trigger only on published releases

jobs:
  update_values:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            git config --global user.email "[email protected]"
            git config --global user.name "pxjssjsjx"
            release_tag=${{ github.event.release.tag_name }}
            # Update the value in the specified file (replace with your details)
            npx yaml-update -f hackkerRankSolutions/actions.yaml version=$release_tag
            git add hackkerRankSolutions/actions.yaml
            git commit -m "Update version to $release_tag in actions.yaml"
            git push origin main
0

There are 0 best solutions below