Skip to content

chore(ci): allow fork to access secrets #3873

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

Merged
merged 3 commits into from
Oct 3, 2024
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
28 changes: 15 additions & 13 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
notification:
runs-on: ubuntu-22.04
timeout-minutes: 1
if: ${{ !github.event.pull_request.head.repo.fork && github.event.number }}
if: ${{ github.event.number }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4

- uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
message: |
### 🪓 The generated code will be pushed at the end of the CI.

Expand Down Expand Up @@ -265,11 +265,11 @@ jobs:
- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
if: ${{ !github.event.pull_request.head.repo.fork && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
if: ${{ env.ALGOLIA_APPLICATION_ID != '' && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-client --no-requests

- name: Retry e2e CTS
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
if: ${{ steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-client --no-requests

- name: Run benchmarks
Expand Down Expand Up @@ -379,11 +379,11 @@ jobs:
- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
if: ${{ !github.event.pull_request.head.repo.fork && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
if: ${{ env.ALGOLIA_APPLICATION_ID != '' && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-client --no-requests

- name: Retry e2e CTS
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
if: ${{ steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-client --no-requests

- name: Run benchmarks
Expand Down Expand Up @@ -479,22 +479,26 @@ jobs:
name: client swift${{ needs.setup.outputs.RUN_MACOS_SWIFT_CTS == 'true' && format('@{0}', fromJSON(needs.setup.outputs.SWIFT_DATA).version) || '' }} macos
steps:
- uses: actions/checkout@v4
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}

- name: Download artifacts
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
uses: ./scripts/ci/actions/restore-artifacts
with:
type: languages
languages: |
swift

- name: Setup
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
uses: ./.github/actions/setup
with:
type: minimal
language: swift
version: ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).version }}

- name: Run tests on macOS
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
id: run-test
continue-on-error: true
run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }} -v ${{ !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') && '--no-e2e' || '' }}
Expand Down Expand Up @@ -528,8 +532,7 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}

- name: Download all artifacts
uses: ./scripts/ci/actions/restore-artifacts
Expand Down Expand Up @@ -572,14 +575,14 @@ jobs:
id: pushGeneratedCode
run: yarn workspace scripts pushGeneratedCode
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}

- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT == '' }}
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
message: |
### No code generated

Expand All @@ -591,7 +594,7 @@ jobs:
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT != '' }}
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
message: |
### ✔️ Code generated!

Expand Down Expand Up @@ -660,9 +663,8 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.codegen.outputs.generatedCommit }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Setup
uses: ./.github/actions/setup
Expand Down
Loading