api-layer
api-layer copied to clipboard
Use github scripts instead of js scripts in GHA
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.
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