api-layer icon indicating copy to clipboard operation
api-layer copied to clipboard

Use github scripts instead of js scripts in GHA

Open CarsonCook opened this issue 2 years ago • 1 comments

We can use this GH shared action: https://github.com/actions/github-script to write JS scripts using github APIs directly in Github Actions workflows, rather than creating external scripts that we currently have in scripts. This is a little cleaner, more obvious of functionality when reading the workflow, and doesn't require npm i or cd commands in the workflow. e.g.

- name: Create pull request
        uses: actions/github-script@v5
        with:
          github-token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
          script: |
            const res = await github.rest.pulls.create({
              owner: 'zowe',
              repo: 'docs-site',
              title: 'Update zwe server command reference',
              body: 'Automatic update of the zwe server command reference',
              head: '${{ env.DOCS_SITE_COMMIT_BRANCH }}',
              base: '${{ env.DOCS_SITE_TARGET_BRANCH }}'
            });
            console.log(`The pull request is at: ${res.data.html_url}`);

Scripts with more custom functionality and custom dependencies may not be able to be used with github-script.

CarsonCook avatar Mar 02 '22 13:03 CarsonCook

1 action has been updated as an example of how it should be done, it is not urgent to update the other 2 as it will not bring much benefit

achmelo avatar Sep 15 '22 10:09 achmelo