I'm trying to save a variable name in one step, using date. But, in a later step, it seems to be undefined (or empty?). What am I missing here?
jobs:
# Create release branch for the week
branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format the date of next Tuesday
id: tuesday
run: echo "abbr=$(date -v+tuesday +'%y%m%d')" >> $GITHUB_ENV
- name: Create a branch with next tuesday's date
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ steps.tuesday.outputs.abbr }}
Error:
refs/heads/release/ is not a valid ref name.
David Gardiner
17.3k20 gold badges86 silver badges126 bronze badges
asked Dec 14, 2020 at 10:24
carpiediem
2,0481 gold badge26 silver badges45 bronze badges
-
If you want to output a value from a step, shouldn't it look more like e.g. github.com/textbook/salary-stats/blob/…? That's what's shown in docs.github.com/en/free-pro-team@latest/actions/reference/… and it works for me.jonrsharpe– jonrsharpe2020年12月14日 10:26:59 +00:00Commented Dec 14, 2020 at 10:26
-
Does this answer your question? Get output of a specific step in github actionssmac89– smac892020年12月14日 16:24:52 +00:00Commented Dec 14, 2020 at 16:24
1 Answer 1
I slightly changed your create branch step but your slo should work if you solve issue with date formatting. enter image description here
I changed it and it works.
jobs:
# Create release branch for the week
branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format the date of next Tuesday
id: tuesday
run: echo "abbr=$(date '+tuesday%y%m%d')" >> $GITHUB_ENV
- name: Read exported variable
run: |
echo "$abbr"
echo "${{ env.abbr }}"
- name: Create a branch with next tuesday's date
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ env.abbr }}
Here a logs from running this:
answered Dec 14, 2020 at 10:43
Krzysztof Madej
42.1k10 gold badges117 silver badges141 bronze badges
Sign up to request clarification or add additional context in comments.
8 Comments
Krzysztof Madej
Are you sure what you are saying. I attached logs which proves different things than you are saying.
Krzysztof Madej
From what i recall ` run: echo "abbr=$(date '+tuesday%y%m%d')" >> $GITHUB_ENV` it created env variable.
smac89
Ahh ok that makes sense now I wasn't aware of the
GITHUB_ENV variableKrzysztof Madej
What can I say more than logs 🙂 both statements were printed, so it appears to be working
|
lang-yaml