From b0327d1fee03ac2f9b1e232dd056f2b8d46faa87 Mon Sep 17 00:00:00 2001 From: Sonja Heinze Date: Tue, 5 Dec 2023 12:50:21 +0100 Subject: [PATCH 1/3] Try to use the action's token with full permissions --- .github/workflows/token_issue.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/token_issue.yml diff --git a/.github/workflows/token_issue.yml b/.github/workflows/token_issue.yml new file mode 100644 index 0000000..99e2bd8 --- /dev/null +++ b/.github/workflows/token_issue.yml @@ -0,0 +1,15 @@ +name: Token issue debugging + +on: + pull_request: + branches: [ main ] + +jobs: + debugging: + runs-on: ubuntu-latest + permissions: write-all + steps: + - name: Write a comment on a PR + run: | + curl -LsX POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -d '{"body":"Hello :)"}' "${{ github.event.pull_request.comments_url }}" + echo $? From 25fec2b25bec485638b86a4e3244c635a4455d7a Mon Sep 17 00:00:00 2001 From: Sonja Heinze Date: Tue, 5 Dec 2023 13:34:19 +0100 Subject: [PATCH 2/3] Try github-script action --- .github/workflows/token_issue.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/token_issue.yml b/.github/workflows/token_issue.yml index 99e2bd8..2b0e8c6 100644 --- a/.github/workflows/token_issue.yml +++ b/.github/workflows/token_issue.yml @@ -9,7 +9,17 @@ jobs: runs-on: ubuntu-latest permissions: write-all steps: - - name: Write a comment on a PR + - name: Write with GH API run: | curl -LsX POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -d '{"body":"Hello :)"}' "${{ github.event.pull_request.comments_url }}" echo $? + - name: Try with github-script action + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '👋 Thanks for reporting!' + }) \ No newline at end of file From 0d3b54b73a89fd92db0c083581976c2a2b79c64e Mon Sep 17 00:00:00 2001 From: Sonja Heinze Date: Tue, 5 Dec 2023 16:26:43 +0100 Subject: [PATCH 3/3] Try a bunch of stuff --- .github/workflows/token_issue.yml | 46 +++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/token_issue.yml b/.github/workflows/token_issue.yml index 2b0e8c6..8d71d7d 100644 --- a/.github/workflows/token_issue.yml +++ b/.github/workflows/token_issue.yml @@ -4,6 +4,10 @@ on: pull_request: branches: [ main ] +env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + + jobs: debugging: runs-on: ubuntu-latest @@ -13,13 +17,37 @@ jobs: run: | curl -LsX POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -d '{"body":"Hello :)"}' "${{ github.event.pull_request.comments_url }}" echo $? - - name: Try with github-script action - uses: actions/github-script@v7 + # - name: Try with github-script action + # uses: actions/github-script@v7 + # with: + # script: | + # github.rest.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body: '👋 Thanks for reporting!' + # }) + + - name: Try to delete a PR label + run: | + curl -sL -w "%{http_code}" -o output.txt -X DELETE -H "Authorization: Bearer $TOKEN" "${{ github.event.pull_request.issue_url }}/labels/invalid" + + - name: Create a dummy file + run: | + mkdir dummy + + - name: Upload data + uses: actions/upload-artifact@v3 with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '👋 Thanks for reporting!' - }) \ No newline at end of file + name: dummy + path: dummy/ + + - name: Try to download an artifact + run: | + all_artifacts=$(curl -sSL ${{ github.event.pull_request.base.repo.url }}/actions/artifacts) + id=$(echo "$all_artifacts" | jq "first(.artifacts[] | .id)") + curl -sSLO -H "Authorization: Bearer $TOKEN" "${{ github.event.pull_request.base.repo.url }}/actions/artifacts/$id/zip" -D headers.txt + + - name: See if artifact is downloaded + run: | + ls -la