Skip to content

Try GITHUB_TOKEN again #65

Try GITHUB_TOKEN again

Try GITHUB_TOKEN again #65

Workflow file for this run

name: Artifacts
on:
push:
branches: [ trying-download-artifact ]
jobs:
download_curl_api_url:
runs-on: ubuntu-latest
# env:
permissions:
actions: read
# Both with and without permissions, I get a 401 with $GITHUB_TOKEN. Use own token instead. Probable problem: Can't give GITHUB_TOKEN permissions in repo scope.
steps:
- name: Ouput id
id: cat_artifact
run: |
cat_data_diff=category-data-pr6-ff3afe34141c544c3f78c1ca03e8bcb3b8c8da74...merge8f268a5b1d0423ed3f6d6f0bf8147c4bb7d09310.diff
gh_api_artifacts_url=https://api.github.com/repos/pitag-ha/merlin/actions/artifacts
all_artifacts=$(curl -sSL $gh_api_artifacts_url)
category_data_artifact=$(echo "$all_artifacts" | jq "first((.artifacts[] | select(.name == \"$cat_data_diff\")) )")
id=$(echo "$category_data_artifact" | jq ".id")
echo "id=$id" | tee -a $GITHUB_OUTPUT
- name: Print the URL
env:
id: ${{ steps.cat_artifact.outputs.id }}
run: echo "https://api.github.com/repos/pitag-ha/merlin/actions/artifacts/$id/zip"
- name: Run curl
env:
id: ${{ steps.cat_artifact.outputs.id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# id: "1043780208"
run: |
curl -LOs -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/pitag-ha/merlin/actions/artifacts/$id/zip" -D headers.txt
- name: Print return headers
run: cat headers.txt
- name: Ls
run: ls
- name: Try unzip
run: unzip zip || cat zip
# download_curl_manual_url:
# runs-on: ubuntu-latest
# permissions: write-all
# steps:
# - name: Run curl
# run: |
# curl -LO -H "Authorization: Bearer $GITHUB_TOKEN" https://github.com/pitag-ha/merlin/suites/18108450661/artifacts/1043818399
# - name: Ls
# run: ls
# - name: cat
# run: cat 1043818399
# upload:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Generate artifact
# run: echo "Hello, World!" > artifact.txt
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: artifact-${{ github.run_number }}
# path: artifact.txt
# download:
# # if: github.event.action == "labelled"
# runs-on: ubuntu-latest
# needs: upload
# permissions: write-all
# steps:
# - name: Sleep
# run: sleep 60
# - name: Download artifact
# uses: dawidd6/action-download-artifact@v2
# with:
# workflow: ${{ github.event.workflow_run.workflow_id }}
# search_artifacts: true
# check_artifacts: true
# - name: Display artifacts
# run: ls artifacts