Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ on:
type: boolean
description: "Boolean to enable running build in windows docker container. Defaults to true"
default: true
needs_token:
type: boolean
description: "Boolean to enable providing the GITHUB_TOKEN to downstream job."
default: false

jobs:
linux-build:
Expand All @@ -80,6 +84,10 @@ jobs:
run: swift --version
- name: Checkout repository
uses: actions/checkout@v4
- name: Provide token
if: ${{ inputs.needs_token }}
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
Comment on lines +87 to +90
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if something like this at call sites would do what you want:

    uses: path/to/my/ci-file
+   secrets: inherit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't work unfortunately. secrets.GITHUB_TOKEN was empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it wasn't the fact it was empty, secrets.GITHUB_TOKEN causes an error
Screenshot 2025-02-05 at 9 45 40 AM

and then github.secrets.GITHUB_TOKEN doesn't cause an error but is empty. And yes secrets is set to inherit

- name: Set environment variables
if: ${{ inputs.linux_env_vars }}
run: |
Expand All @@ -105,6 +113,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Provide token
if: ${{ inputs.needs_token }}
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Set environment variables
if: ${{ inputs.windows_env_vars }}
run: |
Expand Down