|
| 1 | +name: Update dependency proxy release assets |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + tag: |
| 6 | + description: "The tag of CodeQL Bundle release that contains the proxy binaries as release assets" |
| 7 | + type: string |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + update: |
| 12 | + name: Update code and create PR |
| 13 | + timeout-minutes: 15 |
| 14 | + runs-on: macos-latest |
| 15 | + permissions: |
| 16 | + contents: write # needed to push the updated files |
| 17 | + pull-requests: write # needed to create the PR |
| 18 | + steps: |
| 19 | + - name: Install Node |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 # ensure we have all tags and can push commits |
| 26 | + |
| 27 | + - name: Update git config |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 31 | + git config --global user.name "github-actions[bot]" |
| 32 | +
|
| 33 | + - name: Update release tag and version |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + NOW=$(date +"%Y%m%d%H%M%S") # only used to make sure we don't fetch stale binaries from the toolcache |
| 37 | + sed -i '' 's|https://github.com/github/codeql-action/releases/download/codeql-bundle-[0-9.]*/|https://github.com/github/codeql-action/releases/download/${{ inputs.tag }}/|g' ./src/start-proxy-action.ts |
| 38 | + sed -i '' "s/\"v2.0.[0-9]*\"/\"v2.0.$NOW\"/g" ./src/start-proxy-action.ts |
| 39 | +
|
| 40 | + - name: Push changes and open PR |
| 41 | + shell: bash |
| 42 | + env: |
| 43 | + BRANCH: "dependency-proxy/${{ inputs.tag }}" |
| 44 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 45 | + run: | |
| 46 | + set -exu |
| 47 | + pr_title="Update release used by `start-proxy` to ${{ inputs.tag }}" |
| 48 | + pr_body=$(cat << EOF |
| 49 | + This PR updates the `start-proxy` action to use the private registry proxy binaries that |
| 50 | + are attached as release assets to the `${{ inputs.tag }}` release. |
| 51 | +
|
| 52 | +
|
| 53 | + Please do the following before merging: |
| 54 | +
|
| 55 | + - [ ] Verify that the changes to the code are correct. |
| 56 | + EOF |
| 57 | + ) |
| 58 | +
|
| 59 | + git checkout -b "$BRANCH" |
| 60 | +
|
| 61 | + npm run build |
| 62 | + git add ./src/start-proxy-action.ts |
| 63 | + git add ./lib |
| 64 | + git commit -m "$pr_title" |
| 65 | +
|
| 66 | + git push origin "$BRANCH" |
| 67 | + gh pr create \ |
| 68 | + --head "$BRANCH" \ |
| 69 | + --base "main" \ |
| 70 | + --title "${pr_title}" \ |
| 71 | + --body "${pr_body}" \ |
| 72 | + --draft |
0 commit comments