Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure on forked repo - Token secret not supplied #3

Open
3 of 6 tasks
jon-nfc opened this issue Aug 14, 2024 · 7 comments
Open
3 of 6 tasks

Failure on forked repo - Token secret not supplied #3

jon-nfc opened this issue Aug 14, 2024 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jon-nfc
Copy link
Member

jon-nfc commented Aug 14, 2024

On a forked repo the secret is not available. figure out a way to have this workflow run. Test should have already been done in the scratchpad, however they weren't. this was the purpose of nofusscomputing/scratchpad#8

  • ❓ Can the git job token be used??

Run actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e
  with:
    project-url: https://github.com/orgs/nofusscomputing/projects/[3](https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10381144478/job/28742085387#step:2:3)
Error: Input required and not supplied: github-token

Debugging

Proposed Solution 1

Split workflow into two parts. Triage runs in the context of the issue/PR and on completion triggers (workflow_run) the actual workflow which should run in the context of the repo. Idea is the same as this action

for this to work the details of what was triaged will be required to be passed to triggered workflow.

  • triage.yaml
---

name: Triage


on:
  issues:
    types:
      - opened
      - reopened
      - transferred
      - milestoned
      - demilestoned
      - closed
      - assigned
  pull_request: 
    types:
      - opened
      - edited
      - assigned
      - reopened
      - closed


jobs:


  project:
    name: Fetch Triage Details
    runs-on: ubuntu-latest
    steps:

    - name: Collect Triage Details
      shell: bash
      run: |
        echo "triage_event_name=${{ github.event_name }}" > triage_details-project.txt;
        echo "triage_event_action=${{ github.event.action }}" >> triage_details-project.txt;

        if [ "${{ github.event_name }}" == 'pull_request' ]; then
        
          echo "triage_item_number=${{ github.event.pull_request.number }}" >> triage_details-project.txt;

          echo "triage_item_url=https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" >> triage_details-project.txt;

        else

          echo "triage_item_number=${{ github.event.issue.number }}" >> triage_details-project.txt;

          echo "triage_item_url=https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}" >> triage_details-project.txt;

        fi;


        echo "[Debug]************************************";

        cat triage_details-project.txt;

        echo "[Debug]************************************";


      - name: Upload Triage Data
        uses: actions/upload-artifact@v4
        with:
          name: triage-details-project
          path: triage_details-project.txt
  • project.yaml
---

name: 'Project'
on:
  workflow_run:
    workflows:
      - 'Triage'
    types:
      - completed


permissions:
  contents: read
  actions: read


jobs:

  prepare-project-triage: 
    name: Project Triage
    runs-on: ubuntu-latest
    outputs:
      triage_event_name: ${{ steps.triage-output.outputs.triage_event_name }}
      triage_event_action: ${{ steps.triage-output.outputs.triage_event_action }}
      triage_item_number: ${{ steps.triage-output.outputs.triage_item_number }}
      triage_item_url: ${{ steps.triage-output.outputs.triage_item_url }}
    steps:

      ## Additional Steps

      - name: Fetch triage Details
        uses: actions/download-artifact@v4
        with:
          name: triage-details-project
          run-id: ${{ github.event.workflow_run.id }}


      - name: Set Outputs
        id: triage-output
        shell: bash
        run: |
          cat triage_details-project.txt > $GITHUB_OUTPUT


  project:
    name: Project
    needs:
      - prepare-project-triage
    uses: nofusscomputing/action_project/.github/workflows/project.yaml@development
    with:
      PROJECT_URL: https://github.com/orgs/nofusscomputing/projects/3
      TRIAGE_EVENT_NAME: ${{ needs.prepare-project-triage.outputs.triage_event_name }}
      TRIAGE_EVENT_ACTION: ${{ needs.prepare-project-triage.outputs.triage_event_action }}
      TRIAGE_ITEM_NUMBER: ${{ needs.prepare-project-triage.outputs.triage_item_number }}
      TRIAGE_ITEM_URL: ${{ needs.prepare-project-triage.outputs.triage_item_url }}
    secrets:
      WORKFLOW_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

Solution 1 Problem

There does not appear to be a way to specify the item url for action actions/add-to-project

Links

Tasks

  • 🚧 Does "Proposed solution 1" work

    • Update workflow to use proposed TRIAGE_ variables

      TRIAGE_EVENT_NAME: ${{ needs.prepare-project-triage.outputs.triage_event_name }}
      TRIAGE_EVENT_ACTION: ${{ needs.prepare-project-triage.outputs.triage_event_action }}
      TRIAGE_ITEM_NUMBER: ${{ needs.prepare-project-triage.outputs.triage_item_number }}
      TRIAGE_ITEM_URL: ${{ needs.prepare-project-triage.outputs.triage_item_url }}

/cc @jasonpagetas

@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

jon-nfc added a commit that referenced this issue Aug 15, 2024
jon-nfc added a commit that referenced this issue Aug 15, 2024
work in preparation for solution 1

. #3 #4
jon-nfc added a commit that referenced this issue Aug 15, 2024
work in preparation for solution 1

. #3 #4
@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

Test implemented - Solution 1

On merge

@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

Continued Test implemented - Solution 1

Workflows:

  • PR Opened

    • 🟢 triage https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10400895030

      
      Run echo "triage_event_name=pull_request" > triage_details-project.txt;
      [Debug]************************************
      triage_event_name=pull_request
      triage_event_action=assigned
      triage_item_number=23
      triage_item_url=https://github.com/nofusscomputing/ansible_collection_centurion/pull/23
      [Debug]************************************
      
      
      • 🔴 project https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10400897847
        
        Run actions/download-artifact@v4
        with:
            name: triage-details-project
            run-id: 10400895030
            merge-multiple: false
            repository: nofusscomputing/ansible_collection_centurion
        Downloading single artifact
        Error: Unable to download artifact(s): Artifact not found for name: triage-details-project
                Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact.
                For more information, visit the GitHub Artifacts FAQ: https://github.com/actions/toolkit/blob/main/packages/artifact/docs/faq.md
        
        
    • 🟢 triage https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10400895037

      
      Run echo "triage_event_name=pull_request" > triage_details-project.txt;
      [Debug]************************************
      triage_event_name=pull_request
      triage_event_action=opened
      triage_item_number=23
      triage_item_url=https://github.com/nofusscomputing/ansible_collection_centurion/pull/23
      [Debug]************************************
      
      
      • 🔴 project https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10400898004

        
        Run actions/download-artifact@v4
        with:
            name: triage-details-project
            run-id: 10400895037
            merge-multiple: false
            repository: nofusscomputing/ansible_collection_centurion
        Downloading single artifact
        Error: Unable to download artifact(s): Artifact not found for name: triage-details-project
                Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact.
                For more information, visit the GitHub Artifacts FAQ: https://github.com/actions/toolkit/blob/main/packages/artifact/docs/faq.md
        
        

Notes

  • From docs for action actions/download-artifact Artifacts can be downloaded from other workflow runs and repositories when supplied with a PAT.

Merge

workflows: 🔴

@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

Continued Test implemented - Solution 1

workflows:

  • PR Opened

  • PR Assigned:

  • PR Merged

    • 🟢 triage: https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10401341701

    • 🟢 🔴 project https://github.com/nofusscomputing/ansible_collection_centurion/actions/runs/10401344245

      • 🔴 workflow error

        
        The template is not valid. .github/workflows/project.yaml (Line: 50, Col: 27): Unexpected value '24'
        
        
      • 🟢 Step

        
        Run actions/download-artifact@v4
        with:
            name: triage-details-project
            run-id: 10401341701
            github-token: ***
            merge-multiple: false
            repository: nofusscomputing/ansible_collection_centurion
        Downloading single artifact
        Preparing to download the following artifacts:
        - triage-details-project (ID: 1814983798, Size: 281)
        Downloading artifact '1814983798' from 'nofusscomputing/ansible_collection_centurion'
        Redirecting to blob download url: https://productionresultssa13.blob.core.windows.net/actions-results/3493e0bf-8fc6-4730-abf9-44b487d65700/workflow-job-run-b888d68f-cf43-55c6-f18f-461a5106dfc5/artifacts/0c89dc276e2bcccf9193586ee057943561e6ed8684534e5af0f70babd7ce3ea0.zip
        Starting download of artifact to: /home/runner/work/ansible_collection_centurion/ansible_collection_centurion
        (node:1707) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
        (Use `node --trace-deprecation ...` to show where the warning was created)
        Artifact download completed successfully.
        Total of 1 artifact(s) downloaded
        Download artifact has finished successfully
        
        

@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

Continued Test implemented - Solution 1

Notes

jon-nfc added a commit that referenced this issue Aug 15, 2024
@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

Solution 1 - Outcome

moving forward

@jon-nfc
Copy link
Member Author

jon-nfc commented Aug 15, 2024

🟢 Solution 1 - Forked repo test

Success

  • 👍 marking as a success for the forked repo as step fetch triage details uses a PAT and worked from the forked repo.

    • 🔒 The project workflow is run within the context of the parent repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant