1
votes

The problem I'm facing is that the Packer build fails.

This is the error I get: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/vsts-agent/actions-runner/_work/repo/repo/.github/actions/packer-build'. Did you forget to run actions/checkout before running your local action?

The jsonnet steps work fine and they are coming from a custom action as well. Both actions are defined correctly in the repository. When I rerun checkout after the jsonnet steps the packer build works...however, I lose the jsonnet files.

Has anyone found a work around for this? Here is my config

name: Build
on: push
jobs:
  Build_Image:
    name: build
    runs-on: [self-hosted, tsa]
    steps:      
      - uses: azure/[email protected]
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
      - uses: azure/[email protected]
        with:
          keyvault: scotty-packer-nonprod
          secrets: "MANAGED-IMAGE-SUBSCRIPTION-ID"
        id: morePipelineSecrets          
      - uses: azure/[email protected]
        with:
          keyvault: github-actions-nonprod
          secrets: "RESOURCE-GROUP, SUBSCRIPTION-NAME, SUBSCRIPTION-ID, TENANT-ID, RG-CLIENT-ID, RG-CLIENT-SECRET"
        id: pipelineSecrets
      - name: checkout
        uses: actions/checkout@v2       
      - name: jsonnet render template
        uses: ./.github/actions/jsonnet
        with:
          file: packer/ubuntu1804.jsonnet
          output_file: packer/ubuntu1804.json
      - name: jsonnet render vars
        uses: ./.github/actions/jsonnet
        with:
          file: packer/packer-vars.jsonnet
          output_file: packer/packer-vars.json  
      - name: Packer build
        uses: ./.github/actions/packer-build

Directory Structure

repo
  -.github
    -actions
      -jsonnet
         Dockerfile..etc
      -packer-build
         Dockerfile..etc
    -workflows
      -build.yml
1

1 Answers

1
votes

That is weird - the two issues should not be connected. Even weirder is the fact that it works, when checking out the code twice. You have an actions.yml in your packer-build folder?

Nevertheless, possible workaround: Use the actions/upload Action to persist your file.

Like this:

- uses: actions/upload-artifact@v2
  with:
    name: Upload Jsonnet File
    path: packer/ubuntu1804.json

Try to access your second, different action in a new job and get the file with the actions/download-artifact action.