From a09fca075f9d24282356932f621628a41ab762a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 20 Jun 2023 16:05:47 +0200 Subject: [PATCH 1/4] Change authentication method during `git clone` With the previous method, after executing `hub pull-request...` command, `hub` was prompting to provide username and password. Now that we've renamed the API TOKEN secret to `GITHUB_TOKEN`, `hub` recognizes it and does not prompt for the usrname/password. The change has been verified to work, we've succesfully created a PR using this config. --- .github/workflows/reusable-solidity-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-solidity-docs.yml b/.github/workflows/reusable-solidity-docs.yml index 267b156..2c783a7 100644 --- a/.github/workflows/reusable-solidity-docs.yml +++ b/.github/workflows/reusable-solidity-docs.yml @@ -225,14 +225,14 @@ jobs: - name: Sync generated docs with the specified repository and create PR if: inputs.publish == true env: - API_TOKEN_GITHUB: ${{ secrets.githubToken }} + GITHUB_TOKEN: ${{ secrets.githubToken }} run: | echo "▶ Configure environment variables" head_branch=auto-update-solidity-api-docs base_branch=${{ inputs.destinationBaseBranch }} echo "▶ Checkout destination repo" git clone --branch $base_branch \ - https://x-access-token:$API_TOKEN_GITHUB@github.com/${{ inputs.destinationRepo }}.git \ + https://${{ inputs.userName }}:$GITHUB_TOKEN@github.com/${{ inputs.destinationRepo }}.git \ dest-repo-clone echo "▶ Create/checkout head branch" cd dest-repo-clone @@ -256,7 +256,7 @@ jobs: dest_org=$(echo ${{ inputs.destinationRepo }} | cut -d'/' -f1) pr_for_head=$(curl -L \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $API_TOKEN_GITHUB" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/repos/${{ inputs.destinationRepo }}/pulls?status=open&head=$dest_org:$head_branch") if [[ $pr_for_head == $'[\n\n]' ]]; then From 4339b20d856f3032b13895b85a22b68bad2f5111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 20 Jun 2023 17:06:03 +0200 Subject: [PATCH 2/4] Fix typo --- .github/workflows/reusable-solidity-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-solidity-docs.yml b/.github/workflows/reusable-solidity-docs.yml index 2c783a7..10c9d9d 100644 --- a/.github/workflows/reusable-solidity-docs.yml +++ b/.github/workflows/reusable-solidity-docs.yml @@ -4,7 +4,7 @@ name: Generate and push Solidity API documentation # projects's dev dependencies and is configured in Hardhat config (see # https://github.com/OpenZeppelin/solidity-docgen#usage). # The workflow expects `outputDir` to be set to `generated-docs`. You may -# also need to specify other configs, like `temlates` or `exclude`. +# also need to specify other configs, like `templates` or `exclude`. on: workflow_call: inputs: From 57e7962e1ab62973f5ec49984a05499914a48aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 20 Jun 2023 17:13:25 +0200 Subject: [PATCH 3/4] Set Node.js version to 18.15.0 We want to fix problem with the `hardhat compile` command excecuted during building Markdow Docs sometimes not generating expected artifacts. The problem is caused by the process silently quitting, which is related to the used version of Node (as described in NomicFoundation/hardhat#3877). We're setting the version to a fixed `v18.15.0` value, as this is the version that helped with the similar problems in other projects. --- .github/workflows/reusable-solidity-docs.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/reusable-solidity-docs.yml b/.github/workflows/reusable-solidity-docs.yml index 10c9d9d..a49b4c5 100644 --- a/.github/workflows/reusable-solidity-docs.yml +++ b/.github/workflows/reusable-solidity-docs.yml @@ -175,6 +175,13 @@ jobs: shell: bash run: git config --global url."https://".insteadOf git:// + - uses: actions/setup-node@v3 + with: + # Using fixed version, because 18.16 was sometimes causing issues with + # artifacts generation during `hardhat compile` - see + # https://github.com/NomicFoundation/hardhat/issues/3877 + node-version: "18.15.0" + - name: Install dependencies shell: bash run: yarn install --frozen-lockfile From 9f8374392ac5cdc74abe97515e41c8b0d2bb634d Mon Sep 17 00:00:00 2001 From: Michalina Date: Wed, 21 Jun 2023 13:52:07 +0200 Subject: [PATCH 4/4] Switch to a different icon for echoed commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously used `▶` icon was the same as the icon used by GH to sygnalize collapsable content. We're switching to `➞` to not suggest the icon is clickable. --- .github/workflows/reusable-solidity-docs.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/reusable-solidity-docs.yml b/.github/workflows/reusable-solidity-docs.yml index a49b4c5..232c650 100644 --- a/.github/workflows/reusable-solidity-docs.yml +++ b/.github/workflows/reusable-solidity-docs.yml @@ -234,22 +234,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.githubToken }} run: | - echo "▶ Configure environment variables" + echo "➞ Configure environment variables" head_branch=auto-update-solidity-api-docs base_branch=${{ inputs.destinationBaseBranch }} - echo "▶ Checkout destination repo" + echo "➞ Checkout destination repo" git clone --branch $base_branch \ https://${{ inputs.userName }}:$GITHUB_TOKEN@github.com/${{ inputs.destinationRepo }}.git \ dest-repo-clone - echo "▶ Create/checkout head branch" + echo "➞ Create/checkout head branch" cd dest-repo-clone git checkout $head_branch || git checkout -b $head_branch - echo "▶ Synchronize docs" + echo "➞ Synchronize docs" mkdir -p ${{ inputs.destinationFolder }} rsync -avh ${{ inputs.rsyncDelete && '--delete' || '' }} \ ../generated-docs \ ${{ inputs.destinationFolder }} - echo "▶ Commit changes" + echo "➞ Commit changes" git add -A if git status | grep -q "Changes to be committed" then @@ -257,9 +257,9 @@ jobs: git config --global user.name ${{ inputs.userName }} git commit ${{ inputs.verifyCommits && '-S' || '' }} \ -m "Update docs by https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}}" - echo "▶ Push commit" + echo "➞ Push commit" git push --set-upstream origin HEAD:$head_branch - echo "▶ Check if PR for the head branch already exists" + echo "➞ Check if PR for the head branch already exists" dest_org=$(echo ${{ inputs.destinationRepo }} | cut -d'/' -f1) pr_for_head=$(curl -L \ -H "Accept: application/vnd.github+json" \ @@ -267,14 +267,14 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ "https://api.github.com/repos/${{ inputs.destinationRepo }}/pulls?status=open&head=$dest_org:$head_branch") if [[ $pr_for_head == $'[\n\n]' ]]; then - echo "▶ Checked. A PR for the head branch ($head_branch) will be created" + echo "➞ Checked. A PR for the head branch ($head_branch) will be created" hub pull-request --base $base_branch \ --message "Update Solidity API docs" \ --message "Docs updated by workflow: https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}}" else - echo "▶ Checked. A PR for head branch ($head_branch) already exists and got updated." + echo "➞ Checked. A PR for head branch ($head_branch) already exists and got updated." fi else - echo "▶ No changes detected, no commits will be made." + echo "➞ No changes detected, no commits will be made." exit 0 fi