Skip to content

Commit 9de1b55

Browse files
author
Julia
committed
feature: add ability to deploy review apps for PRs from forks
1 parent 2a0e1e9 commit 9de1b55

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This GitHub Action does the following
77
2. **The PR is updated:** it deploys last pushed commit and post a comment to confirm the redeployment
88
3. **The PR is closed (merged or not):** it deletes app and post a comment to confirm the job has been done.
99

10+
The action will consider both branches on the same repository, and pull requests from forks.
11+
1012
## Requirements for this Action
1113

1214
- A [Clever Cloud](https://www.clever-cloud.com) account
@@ -59,8 +61,6 @@ Place this script in your repository in `.github/workflows/` and modify the foll
5961
- `CLEVER_SECRET` and `CLEVER_TOKEN`: find them in your `clever-tools.json` after installing the CLI (example path on Mac: `~/.config/clever-cloud/clever-tools.json`)
6062
- `ORGA_ID`: the organisation in which your app is created
6163

62-
⚠️ This script runs in the context of the base repository and won't work accross forks, because the branch from your fork won't exist in this one. It uses `pull_request_target` as a trigger event to access secrets needed to deploy.
63-
6464
Generally speaking, forks won't have access to secrets [from any base repository](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories-1). This is a GitHub Action security measure and there isn't any way of overriding this using GitHub Actions. **Any pull request from a fork will therefore fail**, consider warning your contributors about this.
6565

6666
## Inject App Secrets

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Clever Cloud Review App on Pull Requests
22

3-
description: Deploy, sync and delete review apps on Clever Cloud for every pull request
3+
description: Deploy, sync and delete review apps on Clever Cloud for every pull request targeting the `main` branch
44

55
on:
66
pull_request_target:
@@ -31,7 +31,9 @@ jobs:
3131
- name: Check out repository code
3232
uses: actions/checkout@v4
3333
with:
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
3435
ref: ${{ github.event.pull_request.head.ref }}
36+
token: ${{ secrets.GITHUB_TOKEN }}
3537
fetch-depth: 0
3638
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
3739
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
@@ -90,7 +92,9 @@ jobs:
9092
- name: Check out repository code
9193
uses: actions/checkout@v4
9294
with:
95+
repository: ${{ github.event.pull_request.head.repo.full_name }}
9396
ref: ${{ github.event.pull_request.head.ref }}
97+
token: ${{ secrets.GITHUB_TOKEN }}
9498
fetch-depth: 0
9599
- name: install clever-tools
96100
run: npm install -g clever-tools

0 commit comments

Comments
 (0)