问题
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/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ steps.tuesday.outputs.abbr }}
Error:
refs/heads/release/ is not a valid ref name.
回答1:
I slightly changed your create branch step but your slo should work if you solve issue with date formatting.
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/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ env.abbr }}
Here a logs from running this:
来源:https://stackoverflow.com/questions/65287308/github-env-variable-in-github-actions