Skip to content

Commit 2bdd0f9

Browse files
authored
feat: allow checkout of fork repository on workflow approval (#1643)
* feat: allow checkout of fork repository on workflow approval Based on #1635 * Do not use secrets if they are not available In the forks, secrets are not available.
1 parent a7c5b02 commit 2bdd0f9

16 files changed

+67
-56
lines changed

.github/workflows/ami-release-nix-single.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout Repo
27-
uses: actions/checkout@v3
27+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2828
with:
2929
ref: ${{ github.event.inputs.branch }}
3030

.github/workflows/ami-release-nix.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
2323
steps:
2424
- name: Checkout Repo
25-
uses: actions/checkout@v3
26-
25+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
26+
2727
- uses: DeterminateSystems/nix-installer-action@main
2828

2929
- name: Set PostgreSQL versions
@@ -48,7 +48,7 @@ jobs:
4848

4949
steps:
5050
- name: Checkout Repo
51-
uses: actions/checkout@v3
51+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5252

5353
- uses: DeterminateSystems/nix-installer-action@main
5454

.github/workflows/check-shellscripts.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
17+
- name: Checkout Repo
18+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
1819
- name: Run ShellCheck
1920
uses: ludeeus/action-shellcheck@master
2021
env:

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout Repo
15-
uses: actions/checkout@v3
15+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
1616

1717
- name: Load postgres_release values
1818
id: load_postgres_release

.github/workflows/dockerhub-release-matrix.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- uses: DeterminateSystems/nix-installer-action@main
2424
- name: Checkout Repo
25-
uses: actions/checkout@v3
25+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2626
- name: Generate build matrix
2727
id: set-matrix
2828
run: |
@@ -53,7 +53,8 @@ jobs:
5353
outputs:
5454
build_args: ${{ steps.args.outputs.result }}
5555
steps:
56-
- uses: actions/checkout@v3
56+
- name: Checkout Repo
57+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5758
- uses: DeterminateSystems/nix-installer-action@main
5859
- name: Set PostgreSQL version environment variable
5960
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
@@ -77,7 +78,8 @@ jobs:
7778
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm-runner' }}
7879
timeout-minutes: 180
7980
steps:
80-
- uses: actions/checkout@v3
81+
- name: Checkout Repo
82+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
8183
- uses: DeterminateSystems/nix-installer-action@main
8284
- run: docker context create builders
8385
- uses: docker/setup-buildx-action@v3
@@ -132,7 +134,8 @@ jobs:
132134
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
133135
runs-on: ubuntu-latest
134136
steps:
135-
- uses: actions/checkout@v3
137+
- name: Checkout Repo
138+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
136139
- uses: DeterminateSystems/nix-installer-action@main
137140
- uses: docker/setup-buildx-action@v3
138141
- uses: docker/login-action@v2
@@ -175,7 +178,8 @@ jobs:
175178
needs: [prepare, merge_manifest]
176179
runs-on: ubuntu-latest
177180
steps:
178-
- uses: actions/checkout@v3
181+
- name: Checkout Repo
182+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
179183
- uses: DeterminateSystems/nix-installer-action@main
180184

181185
- name: Debug Input from Prepare

.github/workflows/manual-docker-release.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: DeterminateSystems/nix-installer-action@main
2121
- name: Checkout Repo
22-
uses: actions/checkout@v3
22+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2323
- name: Generate build matrix
2424
id: set-matrix
2525
run: |
@@ -50,7 +50,8 @@ jobs:
5050
outputs:
5151
build_args: ${{ steps.args.outputs.result }}
5252
steps:
53-
- uses: actions/checkout@v3
53+
- name: Checkout Repo
54+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5455
- uses: DeterminateSystems/nix-installer-action@main
5556
- name: Set PostgreSQL version environment variable
5657
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
@@ -74,7 +75,8 @@ jobs:
7475
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm-runner' }}
7576
timeout-minutes: 180
7677
steps:
77-
- uses: actions/checkout@v3
78+
- name: Checkout Repo
79+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
7880
- uses: DeterminateSystems/nix-installer-action@main
7981
- run: docker context create builders
8082
- uses: docker/setup-buildx-action@v3
@@ -141,7 +143,8 @@ jobs:
141143
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
142144
runs-on: ubuntu-latest
143145
steps:
144-
- uses: actions/checkout@v3
146+
- name: Checkout Repo
147+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
145148
- uses: DeterminateSystems/nix-installer-action@main
146149
- uses: docker/setup-buildx-action@v3
147150
- uses: docker/login-action@v2
@@ -184,7 +187,8 @@ jobs:
184187
needs: [prepare, merge_manifest]
185188
runs-on: ubuntu-latest
186189
steps:
187-
- uses: actions/checkout@v3
190+
- name: Checkout Repo
191+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
188192
- uses: DeterminateSystems/nix-installer-action@main
189193

190194
- name: Debug Input from Prepare

.github/workflows/mirror-postgrest.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
outputs:
1818
postgrest_release: ${{ steps.args.outputs.result }}
1919
steps:
20-
- uses: actions/checkout@v4
20+
- name: Checkout Repo
21+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2122
- id: args
2223
uses: mikefarah/yq@master
2324
with:

.github/workflows/nix-build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ jobs:
2727
runs-on: ${{ matrix.runner }}
2828
timeout-minutes: 180
2929
steps:
30-
31-
- name: Check out code
32-
uses: actions/checkout@v4
33-
with:
34-
ref: ${{ github.event.pull_request.head.ref || github.ref }}
35-
fetch-depth: 0
36-
fetch-tags: true
30+
- name: Checkout Repo
31+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
3732
- name: aws-creds
3833
uses: aws-actions/configure-aws-credentials@v4
34+
if: ${{ github.secret_source == 'Actions' }}
3935
with:
4036
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
4137
aws-region: "us-east-1"
@@ -48,7 +44,7 @@ jobs:
4844
env:
4945
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
5046
- name: Log in to Docker Hub
51-
if: matrix.runner != 'macos-latest' && matrix.runner != 'macos-13'
47+
if: matrix.runner != 'macos-latest' && matrix.runner != 'macos-13' && github.secret_source == 'Actions'
5248
uses: docker/login-action@v2
5349
with:
5450
username: ${{ secrets.DOCKER_USERNAME }}

.github/workflows/publish-migrations-prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
env:
2222
GITHUB_REF: ${{ github.ref }}
2323

24-
- name: Checkout Repo
25-
uses: actions/checkout@v2
24+
- name: Checkout repo
25+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2626

2727
- name: Merging migration files
2828
run: cat $(ls -1) > ../migration-output.sql

.github/workflows/publish-migrations-staging.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout Repo
19-
uses: actions/checkout@v2
20-
19+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2120
- name: Merging migration files
2221
run: cat $(ls -1) > ../migration-output.sql
2322
working-directory: ${{ github.workspace }}/migrations/db/migrations

.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
1818
steps:
1919
- name: Checkout Repo
20-
uses: actions/checkout@v3
21-
20+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
21+
2222
- uses: DeterminateSystems/nix-installer-action@main
2323

2424
- name: Set PostgreSQL versions
@@ -36,8 +36,8 @@ jobs:
3636

3737
steps:
3838
- name: Checkout Repo
39-
uses: actions/checkout@v3
40-
39+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
40+
4141
- uses: DeterminateSystems/nix-installer-action@main
4242

4343
- name: Grab release version
@@ -88,7 +88,7 @@ jobs:
8888

8989
steps:
9090
- name: Checkout Repo
91-
uses: actions/checkout@v3
91+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
9292

9393
- name: Grab release version
9494
id: process_release_version

.github/workflows/publish-nix-pgupgrade-scripts.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
2525
steps:
2626
- name: Checkout Repo
27-
uses: actions/checkout@v3
27+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2828

2929
- uses: DeterminateSystems/nix-installer-action@main
3030

@@ -43,7 +43,7 @@ jobs:
4343

4444
steps:
4545
- name: Checkout Repo
46-
uses: actions/checkout@v3
46+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
4747

4848
- uses: DeterminateSystems/nix-installer-action@main
4949

@@ -94,8 +94,8 @@ jobs:
9494

9595
steps:
9696
- name: Checkout Repo
97-
uses: actions/checkout@v3
98-
97+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
98+
9999
- uses: DeterminateSystems/nix-installer-action@main
100100

101101
- name: Grab release version

.github/workflows/qemu-image-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
2424
steps:
2525
- name: Checkout Repo
26-
uses: actions/checkout@v3
26+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2727

2828
- uses: DeterminateSystems/nix-installer-action@main
2929

@@ -47,7 +47,7 @@ jobs:
4747

4848
steps:
4949
- name: Checkout Repo
50-
uses: actions/checkout@v3
50+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5151

5252
- uses: DeterminateSystems/nix-installer-action@main
5353

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
1818
steps:
1919
- name: Checkout Repo
20-
uses: actions/checkout@v4
20+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
2121

2222
- name: Clear Nix cache
2323
run: |
@@ -49,7 +49,8 @@ jobs:
4949
POSTGRES_PORT: 5478
5050
POSTGRES_PASSWORD: password
5151
steps:
52-
- uses: actions/checkout@v4
52+
- name: Checkout Repo
53+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5354
- name: Clear Nix cache
5455
run: |
5556
sudo rm -rf /home/runner/.cache/nix
@@ -86,4 +87,4 @@ jobs:
8687
echo "Detected changes in schema.sql:"
8788
git diff migrations/schema-${{ env.PGMAJOR }}.sql
8889
exit 1
89-
fi
90+
fi

.github/workflows/testinfra-ami-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
1616
steps:
1717
- name: Checkout Repo
18-
uses: actions/checkout@v4
18+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
1919

2020
- uses: DeterminateSystems/nix-installer-action@main
2121

@@ -52,7 +52,7 @@ jobs:
5252

5353
steps:
5454
- name: Checkout Repo
55-
uses: actions/checkout@v4
55+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
5656

5757
- id: args
5858
uses: mikefarah/yq@master

docker/nix/build_nix.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ nix build .#wal-g-2 -o wal-g-2 -L
1818
nix build .#wal-g-3 -o wal-g-3 -L
1919

2020
# Copy to S3
21-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./wal-g-2
22-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./wal-g-3
23-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15
24-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_orioledb_17
25-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_17
21+
if [[ -n "${AWS_ACCESS_KEY_ID-}" && -n "${AWS_SECRET_ACCESS_KEY-}" ]]; then
22+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./wal-g-2
23+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./wal-g-3
24+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15
25+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_orioledb_17
26+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_17
27+
fi
2628

2729
if [ "$SYSTEM" = "aarch64-linux" ]; then
2830
nix build .#postgresql_15_debug -o ./postgresql_15_debug
@@ -31,10 +33,13 @@ if [ "$SYSTEM" = "aarch64-linux" ]; then
3133
nix build .#postgresql_orioledb-17_src -o ./postgresql_orioledb-17_src
3234
nix build .#postgresql_17_debug -o ./postgresql_17_debug
3335
nix build .#postgresql_17_src -o ./postgresql_17_src
34-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_15_debug-debug
35-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_15_src
36-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_orioledb-17_debug-debug
37-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_orioledb-17_src
38-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_17_debug-debug
39-
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_17_src
36+
37+
if [[ -n "${AWS_ACCESS_KEY_ID-}" && -n "${AWS_SECRET_ACCESS_KEY-}" ]]; then
38+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_15_debug-debug
39+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_15_src
40+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_orioledb-17_debug-debug
41+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_orioledb-17_src
42+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_17_debug-debug
43+
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./postgresql_17_src
44+
fi
4045
fi

0 commit comments

Comments
 (0)