I am trying to use a combination of branch name and github run number as the image tag in my github actions ci/cd process
Long story short: I want to have MODIFIED_BRANCH_NAME set as an environment variable and use it later
this is my workflow file
name: CI/CD mktplc-catalog
on:
push:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
MODIFIED_BRANCH_NAME: # What goes here?
.
.
.
suppose the branch name is feature/add-foo I need MODIFIED_BRANCH_NAME to be set as feature-add-foo
How should I do this?
You could use shell parameter expansion adding an extra step, like:
steps:
- name: Sets MODIFIED_BRANCH_NAME
env:
name: "${{env.BRANCH_NAME}}"
run: |
echo "MODIFIED_BRANCH_NAME=${name/\//-}" >> $GITHUB_ENV
Tested here https://github.com/mbiagetti/github-action-poc/pull/1
You could test shell expansion with the code:
>name=feature/add-foo
>MODIFIED_BRANCH_NAME=${name/\//-}
>echo $MODIFIED_BRANCH_NAME
feature-add-foo
For multiple jobs requirement, check this PR https://github.com/mbiagetti/github-action-poc/pull/2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With