Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 12

Support for YAML anchors

Trying to use YAML anchors results in this error message:

Anchors are not currently supported. Remove the anchor '{anchor-name}'


Currently, there is no easy way to reuse steps. Having to write JS to define actions is completely overkill if I just want to reuse some commands in different jobs.

11 Replies
Community Manager
Message 2 of 12

Re: Support for YAML anchors

Thanks for the feedback! I've taken your suggestion and passed it along to the appropriate teams. Thanks again for reaching out 😀


Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Ground Controller Lvl 1
Message 3 of 12

Re: Support for YAML anchors

Has there been any action on this?

Ground Controller Lvl 1
Message 4 of 12

Re: Support for YAML anchors

This is really a must to make GH Actions a compelling choice over the established CI providers. Travis uses a YAML format as well but supports anchors, which makes it about 1/5 the size of a GH workflow file which does the same thing. Please support YAML anchors! 🙏

Copilot Lvl 2
Message 5 of 12

Re: Support for YAML anchors

This applies to YAML aliases as well. I didn't realize aliases could even be unsupported.

### ERRORED 21:44:58Z

- Your workflow file was invalid: .github/workflows/deploy.yml: Anchors are not currently supported. Remove the anchor 'setup_elixir'

And this is the most basic thing. Trying to reuse some settings in another job so that versions can be seen and updated in one place (at least, one place within this file).

steps:
      - uses: actions/checkout@v1
      - &setup_elixir
        uses: actions/setup-elixir@v1.0.0
        with:
          otp-version: 22.x
          elixir-version: 1.9.x

And later on:

- *setup_elixir

Ideally, I'd like to define some things at the top-level so that they are all at the top of the file. Unfortunately an abitrary top-level node isn't allowed:

- Your workflow file was invalid: .github/workflows/deploy.yml (Line: 9, Col: 1): Unexpected value 'aliases'

I've seen examples for Docker (Compose) that allow anything beginning with x, e.g. x-whatever.

Ground Controller Lvl 2
Message 6 of 12

Re: Support for YAML anchors

I second that. Currently there is no way to reuse steps in actions, so we need to copy-paste them everywhere, which makes GitHub actions more a toy than a real tool here :(

Highlighted
Copilot Lvl 3
Message 7 of 12

Re: Support for YAML anchors

Would be great to have support for anchors.

Copilot Lvl 3
Message 8 of 12

Re: Support for YAML anchors

Any news on this? This quite an esential feature for CI pipelines.

Copilot Lvl 3
Message 9 of 12

Re: Support for YAML anchors

To echo what the other commenters have said, this is really needed.

 

I'm currently trying to migrate a lot of our pipelines to Github Actions and the amount of copy / pasting per job is immense, for eg. 

 

 
  build:
    name: Build
    needs: cache
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Cache Yarn
        uses: actions/cache@v1
        with:
          path: ~/.cache/yarn
          key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - run: |
          echo "//npm.pkg.github.com/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
          echo "@attest:registry=https://npm.pkg.github.com/" >> ~/.npmrc
          yarn --frozen-lockfile
        env:
          NODE_AUTH_TOKEN: ${{secrets.ADMIN_GH_TOKEN}}
      - run: yarn build
 

 

If I want to run each job in parallel I need to copy and paste the above steps for each one (6 currently) which is making it quite difficult to read and maintain

 

Am getting to the point of considering building out these yml files from a source that does support some sort of include or anchoring method.

Pilot Lvl 1
Message 10 of 12

Re: Support for YAML anchors

@csi-lk It's not obvious what you want to do from that snippet. But have you looked at https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-...