As other answers are either incomplete or sidetracked, here is it straightforward :
Add a pound sign (#
) and the rest of the line is commented, which is the standard YAML way to add a comment.
Do note that a whitespace is required between the #
and the comment.
Usually it is a good practice for readability to just put it at the beginning of the line and have the comment on its own line.
jobs:
testing:
name: some test
runs-on: [ self-hosted, linux, xyz ]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.0
id: go
- name: Configure git client
# run git client to fix some issue
run: git config --global url."ssh://[email protected]:".insteadOf "https://github.com/"
As the Stackoverflow preview will show you, it is added as a comment.
Now if, like me, you ended up here because your comment is not showing as a comment in VS Code, and you are using the Github Actions extension (the official one by Github), there is no special way to add comment in Github Actions, it is just a bug of the extension that does not highlight comments correctly if they contain templating syntax. See : https://github.com/github/vscode-github-actions/issues/158