From 87bbf557c1544f77d94d9b878edb53ed87ae3f4f Mon Sep 17 00:00:00 2001 From: marocchino Date: Sat, 25 Mar 2023 10:05:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=B7=20Update=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/comment_on_workflow_run.yml | 40 ------------------- .github/workflows/test.yml | 27 ++++++++++--- 2 files changed, 22 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/comment_on_workflow_run.yml diff --git a/.github/workflows/comment_on_workflow_run.yml b/.github/workflows/comment_on_workflow_run.yml deleted file mode 100644 index 7c4eb40..0000000 --- a/.github/workflows/comment_on_workflow_run.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Comment on Workflow Run - -on: - workflow_run: - workflows: - - "Test" - types: - - completed - -jobs: - comment: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.event == 'pull_request' }} - steps: - - uses: actions/checkout@v3 - - name: on artifact - id: artifact - uses: marocchino/on_artifact@v1 - with: - name: all - - uses: ./ - with: - header: All - number: ${{ steps.artifact.outputs.number }} - message: | -
- output of yarn all - - ``` - ${{ steps.artifact.outputs.all_result }} - ``` -
- - uses: ./ - with: - header: All - number: ${{ steps.artifact.outputs.number }} - append: true - hide_details: true - message: | - The build is over. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69642c7..23f8431 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,9 +15,26 @@ jobs: set -o pipefail mkdir -p ./pr echo ${{ github.event.number }} | tee ./pr/number - yarn all |& tee ./pr/all_result - - uses: actions/upload-artifact@v3 - if: ${{ github.event_name == 'pull_request' && (success() || failure()) }} + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "all_result<<$EOF" >> "$GITHUB_ENV" + yarn all >> "$GITHUB_ENV" + echo "$EOF" >> "$GITHUB_ENV" + id: all + - uses: ./ with: - name: all - path: pr/ + header: All + message: | +
+ output of yarn all + + ``` + ${{ env.all_result }} + ``` +
+ - uses: ./ + with: + header: All + append: true + hide_details: true + message: | + The build is over. From 68f49e0cabcfda29589eee75f22477f256ef865b Mon Sep 17 00:00:00 2001 From: marocchino Date: Sat, 25 Mar 2023 10:08:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Update=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f91624b..acb54f5 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,13 @@ This library runs with GitHub Actions. If you feel that the example grammar belo ### Basic +You need to add permissions for this tool. + +```yaml +permissions: + pull-requests: write +``` + ```yaml uses: marocchino/sticky-pull-request-comment@v2 with: @@ -30,19 +37,17 @@ release: test: ... - name: Run Test - id: test run: | - OUTPUT=$(rake test) - OUTPUT="${OUTPUT//'%'/'%25'}​【7,6 m】" - OUTPUT="${OUTPUT//$'\n'/'%0A'}" - OUTPUT="${OUTPUT//$'\r'/'%0D'}" - echo "result=$OUTPUT" >> $GITHUB_OUTPUT + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "test_result<<$EOF" >> "$GITHUB_ENV" + rake test >> "$GITHUB_ENV" + echo "$EOF" >> "$GITHUB_ENV" - uses: marocchino/sticky-pull-request-comment@v2 with: header: test message: | ``` - ${{ steps.test.outputs.result }} + ${{ env.test_result }} ``` ```` @@ -52,20 +57,18 @@ test: test: ... - name: Run Test - id: test run: | - OUTPUT=$(rake test) - OUTPUT="${OUTPUT//'%'/'%25'}​【7,6 m】" - OUTPUT="${OUTPUT//$'\n'/'%0A'}" - OUTPUT="${OUTPUT//$'\r'/'%0D'}" - echo "result=$OUTPUT" >> $GITHUB_OUTPUT + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "test_result<<$EOF" >> "$GITHUB_ENV" + rake test >> "$GITHUB_ENV" + echo "$EOF" >> "$GITHUB_ENV" - uses: marocchino/sticky-pull-request-comment@v2 with: append: true message: | Test with ${{ github.sha }}. ``` - ${{ steps.test.outputs.result }} + ${{ env.test_result }} ``` ```` @@ -134,8 +137,18 @@ with: ### Error: Resource not accessible by integration -This message means the requester does not have enough permission. If `secrets.GITHUB_TOKEN` -is explicitly passed, this problem can be solved by just removing it. +This tool requires write permission, and that message means the requester does not have enough permission. +Recently, GitHub sets permissions conservatively for newly created repositories. If it's a newly created repository, check your Settings > Actions > General > Workflow permissions, and make sure to enable read and write permissions. + +Then, you can specify permissions for the job like this: + +```yaml +permissions: + pull-requests: write +``` + +For more detailed information about permissions, you can read from the link below: + ## Inputs