I'm making a github action that edits the README by adding the name of the PR assignees when a pull request is merged. I tried to set a environment variable to use in my python code with the value of ${{github.event.pull_request.assignees}}
however I'm getting the following error when running an exemple PR merge:
Error: The template is not valid.
.github/workflows/main.yml (Line: 32, Col: 22): A sequence was not expected
This is my current code:
name: READMEUPDATER
on:
pull_request:
types: [ closed ]
branches: [ main ]
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Edit the README.md
if: |
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'workshop')
run: |
python ./scripts/updater.py
git add README.md
git commit -m "Auto update to README.md"
git fetch origin master
git push origin HEAD:master
env:
repo: ${{github.event.pull_request.base.repo.name}}
assignees: ${{github.event.pull_request.assignees}}
CodePudding user response:
I did manage to solve it, the problem was that it was parsing it as a list not a string to the assignees variables, so I just used this: ${{toJson(github.event.pull_request.assigness)}}
. It serializes the list to a json string. And also the commit part was missing the git config user.name "xxx"
.