Reputation: 86097
Running code from https://docs.github.com/en/free-pro-team@latest/actions/quickstart
why does this code create a syntax error:
- name: Checkout code
uses: actions/checkout@v2
but this is fine:
- name: Checkout code
uses: actions/checkout@v2
According to this YAML How many spaces per indent? there are no indentation requirements for YAML.
Upvotes: 12
Views: 19728
Reputation: 4336
It's correct that the number of spaces can be freely chosen, but for the same node it has to be equal.
This is a mapping with two keys:
name: Checkout code
uses: actions/checkout@v2
but if you write it like this:
name: Checkout code
uses: actions/checkout@v2
then the uses: ...
is seen as a continuation of the previous value for name
. But it's invalid, because colons plus spaces aren't allowed in mapping values.
If it looked like that:
name: Checkout code
more
it would be valid YAML, equal to:
name: Checkout code more
So inside of that mapping, always use the same amount of spaces.
May I also recommend my short tutorial?
Upvotes: 14