Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support use of output from synth step as input in later ShellSteps #364

Open
giseburt opened this issue Oct 10, 2022 · 1 comment
Open

Comments

@giseburt
Copy link
Contributor

I would expect this code to work:

    const pipeline = new GitHubWorkflow(app, 'Pipeline', {
      workflowPath: `${dir}/.github/workflows/deploy.yml`,
      synth: new ShellStep('Build', {
        installCommands: ['yarn'],
        commands: ['yarn build'],
      }),
      jobSettings: { if: 'check on Synthesize and Publish Assets' },
    });

    const stage = new Stage(app, 'MyStage', {
      env: { account: '111111111111', region: 'us-east-1' },
    });

    new Stack(stage, 'MyStack');


    pipeline.addStageWithGitHubOptions(stage, {
      pre: [
        new ShellStep('Extra-Shell-Step', {
          additionalInputs: {
            'cdk.out': pipeline.cloudAssemblyFileSet,
          },
          commands: ['ls -al cdk.out'],
        }),
      ],
    });

The resulting yaml file doesn't work, since the uploaded artifact is named "cdk.out" but the id used as the name from the pipeline.cloudAssemblyFileSet is `"Output":

      Build-Build:
        name: Synthesize
        if: check on Synthesize and Publish Assets
        permissions:
          contents: read
          id-token: none
        runs-on: ubuntu-latest
        needs: []
        env: {}
        steps:
          - name: Checkout
            uses: actions/checkout@v2
          - name: Install
            run: yarn
          - name: Build
            run: yarn build
          - name: Upload cdk.out
            uses: actions/[email protected]
            with:
              name: cdk.out # ← here ⚠️
              path: cdk.out

And later:

      MyStage-Extra-Shell-Step:
        name: Extra-Shell-Step
        if: check on Synthesize and Publish Assets
        permissions:
          contents: read
        runs-on: ubuntu-latest
        needs:
          - Build-Build
        env: {}
        steps:
          - uses: actions/download-artifact@v2
            with:
              name: Output  # ← here ⚠️
              path: cdk.out
          - run: ls -al cdk.out

The name Output is coming from @aws-cdk/pipelines/lib/blueprint/shell-step.ts:

    if (props.primaryOutputDirectory) {
      this._primaryOutputDirectory = props.primaryOutputDirectory;
      const fileSet = new FileSet('Output', this);  // ← here ⚠️
      this.configurePrimaryOutput(fileSet);
      this.outputs.push({ directory: props.primaryOutputDirectory, fileSet });
    }

Perhaps I'm wrong, but it appears that by using this.cloudAssemblyFileSet.id instead of CDKOUT_ARTIFACT here and here this would work as expected.

@giseburt
Copy link
Contributor Author

I forgot to add that I already have a PR for this teed up as well, just waiting to hear feedback in case it needs adjusted or maybe there's a bigger plan that I'd be invalidating here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant