-
Notifications
You must be signed in to change notification settings - Fork 0
(#22) Revert "(#19) Use shared workflow." #23
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,12 +12,147 @@ | |
| tags: | ||
| - '*' | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| ci_remote: | ||
| uses: nciocpl/launchables/.github/workflows/workflow.yml@ticket/1-workflow | ||
| permissions: | ||
| contents: read | ||
| packages: read # For npm install from GH Packages | ||
| pull-requests: write # For adding comments to PRs | ||
| secrets: inherit | ||
| build: | ||
| name: Build, Test and Upload Artifacts | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| ## Setup variables for build info | ||
| - name: Set Variables | ||
| id: set_vars | ||
| run: | | ||
| ## PUSH | ||
| if [ "${{ github.event_name }}" == "push" ]; then | ||
| BUILD_NAME=$(sed -E 's/refs\/(heads|tags)\///; s/\//__/g;' <<< $GITHUB_REF) | ||
| BRANCH_NAME=$(sed -E 's/refs\/(heads|tags)\///;' <<< $GITHUB_REF) | ||
| COMMIT_HASH=$(echo "${GITHUB_SHA}") | ||
| ## PULL_REQUEST | ||
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | ||
| BUILD_NAME=$(echo "pr-${{ github.event.pull_request.number }}") | ||
| BRANCH_NAME=$(echo "pr-${{ github.event.pull_request.number }}") | ||
| COMMIT_HASH=$(echo "${{ github.event.pull_request.head.sha }}") | ||
| else | ||
| ## ERROR | ||
| exit 1 | ||
| fi | ||
| ## For step checks and artifact deployment path. | ||
| ## Same for push and PR | ||
| export REPO_FULL=${{ github.repository }} | ||
| export REPO_RE='([^/]+)/(.*)' | ||
| [[ "$REPO_FULL" =~ $REPO_RE ]] | ||
| REPO_OWNER=$(echo "${BASH_REMATCH[1]}") | ||
| REPO_NAME=$(echo "${BASH_REMATCH[2]}") | ||
| ## Set step outputs for later use | ||
| echo "build_name=${BUILD_NAME}" >> $GITHUB_OUTPUT | ||
| echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
| echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT | ||
| echo "repo_owner=${REPO_OWNER}" >> $GITHUB_OUTPUT | ||
| echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT | ||
| ## This clones and checks out. | ||
| - name: Checkout branch | ||
| uses: actions/checkout@v4 | ||
| ## Setup node and npm caching. | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
| registry-url: https://npm.pkg.github.com | ||
| scope: '@nciocpl' | ||
| cache-dependency-path: '**/package-lock.json' | ||
| ## Install dependencies | ||
| - name: Install Dependencies | ||
| run: npm ci | ||
| env: | ||
| CI: true | ||
| NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
| ## Check Formatting | ||
| - name: Check Formatting | ||
| run: npm run format:check | ||
| ## Lint | ||
| - name: Lint | ||
| run: npm run lint | ||
| ## Build the app in prep for publishing | ||
| - name: Build App | ||
| run: npm run build | ||
| env: | ||
| CI: true | ||
| ## Set public Base path for branch | ||
| PUBLIC_PATH: ${{ format('/launchables/{0}/{1}', steps.set_vars.outputs.repo_name, steps.set_vars.outputs.build_name) }} | ||
| ## Generate build-info.json to house information about this specific build. | ||
| ## Used for product test deployment | ||
| - name: Create Build Information | ||
| env: | ||
| BUILD_INFO: ${{ toJson(steps.set_vars.outputs) }} | ||
| run: | | ||
| echo $BUILD_INFO | ||
| echo $BUILD_INFO > ./dist/build-info.json | ||
| - name: Archive production artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: build-artifact | ||
| path: dist/ | ||
| deploy-test: | ||
| name: Deploy built artifacts to test server | ||
| ## Only do this if the repo is NCIOCPL | ||
| if: startsWith(github.repository, 'NCIOCPL') | ||
| ## This job depends on build completing | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download built app | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: build-artifact | ||
| path: build-artifact | ||
| ## Setup vars from Build Info from build job | ||
| - name: Setup Job env | ||
| run: | | ||
| ls -l | ||
| ## Set Vars | ||
| BUILD_NAME=$(jq -r '.build_name' < ./build-artifact/build-info.json) | ||
| BRANCH_NAME=$(jq -r '.branch_name' < ./build-artifact/build-info.json) | ||
| COMMIT_HASH=$(jq -r '.commit_hash' < ./build-artifact/build-info.json) | ||
| REPO_OWNER=$(jq -r '.repo_owner' < ./build-artifact/build-info.json) | ||
| REPO_NAME=$(jq -r '.repo_name' < ./build-artifact/build-info.json) | ||
| ## Set Action Env | ||
| echo "BUILD_NAME=${BUILD_NAME}" >> $GITHUB_ENV | ||
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | ||
| echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV | ||
| echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_ENV | ||
| echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV | ||
| ######## ERROR IF PR FROM FORK | ||
| if [ "$REPO_OWNER" != "NCIOCPL" ]; then | ||
| echo "YOU SHOULD NOT SEND PR FROM FORK!!!" | ||
| exit 1 | ||
| fi | ||
| ## We need to create the zip for netstorage | ||
| - name: Zip Build Artifact | ||
| run: | | ||
| pushd build-artifact | ||
| zip -r ../${BUILD_NAME}.zip * | ||
| popd | ||
| - name: Upload artifact to netstorage | ||
| uses: nciocpl/[email protected] | ||
| with: | ||
| hostname: ${{ secrets.launchables_ns_hostname }} | ||
| cp-code: ${{ secrets.launchables_ns_cpcode }} | ||
| key-name: ${{ secrets.launchables_ns_keyname }} | ||
| key: ${{ secrets.launchables_ns_key }} | ||
| index-zip: true | ||
| local-path: ${{ format('{0}.zip', env.BUILD_NAME) }} | ||
| ## Note this action automatically prepends the cpcode to the path. | ||
| destination-path: ${{ format('/{0}/{1}.zip', env.REPO_NAME, env.BUILD_NAME) }} | ||
| - name: Clear Site Cache | ||
| uses: nciocpl/[email protected] | ||
| with: | ||
| hostname: ${{ secrets.launchables_eg_hostname }} | ||
| client-token: ${{ secrets.launchables_eg_client_token }} | ||
| client-secret: ${{ secrets.launchables_eg_client_secret }} | ||
| access-token: ${{ secrets.launchables_eg_access_token }} | ||
| type: 'cpcodes' | ||
| ref: ${{ format('{0},{1}', secrets.launchables_ns_cpcode, secrets.launchables_prop_cpcode) }} | ||
|
Comment on lines
+98
to
+158
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium