Closed alex-page closed 2 years ago
Hi Alex
This should be doable by defining the commit_hash
using output parameters.
For your usecase this would look like this
echo "::set-output name=commit_hash::$(git ls-remote https://github.com/Shopify/polaris.git refs/heads/main | cut -c1-7)";
The entire updated workflow would look like this:
name: Trigger deploy
on:
workflow_dispatch:
jobs:
trigger-deploy:
runs-on: self-hosted
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Set COMMIT_HASH
id: commit-hash
run: |
echo COMMIT_HASH=`git ls-remote https://github.com/Shopify/polaris.git refs/heads/main | cut -c1-7` >> $GITHUB_ENV
# Create a new `commit_hash` output parameter for this workflow step
echo "::set-output name=commit_hash::$(git ls-remote https://github.com/Shopify/polaris.git refs/heads/main | cut -c1-7)";
- name: Update version file
run: echo $COMMIT_HASH > version
- name: Commit version file
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Use the ID of the step to get the calculated commit_hash
commit_message: "deploy ${{ steps.commit-hash.outputs.commit_hash }}"
skip_dirty_check: true
commit_options: "--allow-empty"
Legend. Thank you @stefanzweifel, this worked perfectly.
Is your feature request related to a problem? Please describe.
Not really, it's just an enhancement that could make this action nice to use. BTW this action is great, thank you.
Describe the solution you'd like
I would like to customise the commit message with env variables
$GITHUB_SHA
or other shell scripts likedate
. In shell you can do something like:Describe alternatives you've considered
I tried a bunch of different approaches but it always seems to render out the string of the environment variable. I might be doing something incorrect.
Additional context
This is the GitHub action I made and the environment variable has the correct value but it's not adding it to the commit message.
I also tried a bunch of variations: