Here is a github workflow that I would like to use to create a release.
name: make release
on:
workflow_dispatch:
jobs:
try-to-create-a-tag:
runs-on: ubuntu-latest
steps:
- name: Create release
run: curl \
-X POST \
-H "Accept:application/vnd.github json" \
-H "Authorization:token ${ secrets.GITHUB_TOKEN }" \
https://api.github.com/repos/.../releases \
-d '{"tag_name":"tag_test11","target_commitish":"main","name":"tag_test11","body":"Description of the release","draft":false,"prerelease":false,"generate_release_notes":false}'
The workflow runs without error, however I get the following message from curl:
authorization:token ${ secrets.GITHUB_TOKEN }: bad substitution
I have also tried using double braces, however this didn't work either. How can I substitute the variable into the curl command?
NOTE: the error is that one must use a |
right after run:
when splitting over multiple lines.
CodePudding user response:
You have to use double brackets:
${{ secrets.GITHUB_TOKEN }}
Documentation: https://docs.github.com/en/actions/security-guides/encrypted-secrets#example-using-bash
jobs:
try-to-create-a-tag:
runs-on: ubuntu-latest
steps:
- name: Create release
run: |
curl \
-X POST \
-H "Accept:application/vnd.github json" \
-H "Authorization:token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/.../releases \
-d '{"tag_name":"tag_test11","target_commitish":"main","name":"tag_test11","body":"Description of the release","draft":false,"prerelease":false,"generate_release_notes":false}'