Skip to content

Commit 9c290a6

Browse files
chore: disable bot's commit & push in forks
1 parent fca1b15 commit 9c290a6

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
env:
3232
VERBOSE: 0
3333
PYTHONUNBUFFERED: 1
34-
DATA_AWS_S3_BUCKET: ${{ secrets.DATA_AWS_S3_BUCKET }}
35-
DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
36-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
37-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38-
AWS_DEFAULT_REGION: us-east-2
3934
GH_TOKEN: ${{ github.token }}
4035

4136
steps:
@@ -44,7 +39,7 @@ jobs:
4439
with:
4540
fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags.
4641
fetch-tags: true # Whether to fetch tags, even if fetch-depth > 0.
47-
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
42+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
4843

4944
- name: "Install system dependencies"
5045
run: |
@@ -54,33 +49,56 @@ jobs:
5449
run: |
5550
pip3 install -r requirements.txt
5651
57-
- name: "Install awscli"
52+
- name: "DEBUG"
5853
run: |
59-
pushd /tmp >/dev/null
60-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
61-
unzip -oqq awscliv2.zip
62-
sudo ./aws/install --update
63-
popd >/dev/null
64-
aws --version
54+
echo 'github.event.pull_request.head.repo.fork =' ${{ github.event.pull_request.head.repo.fork }}
55+
echo 'github.event.pull_request.head.repo.full_name =' ${{ github.event.pull_request.head.repo.full_name }}
56+
echo 'github.event.pull_request.base.repo.full_name =' ${{ github.event.pull_request.base.repo.full_name }}
57+
echo 'github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name =' ${{ github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name }}
58+
echo '(github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name) == github.repository =' ${{ (github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name) == github.repository }}
59+
echo 'github.event.pull_request.head.repo.fork || ((github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name) == github.repository) =' ${{ github.event.pull_request.head.repo.fork || ((github.event.pull_request.head.repo.full_name || github.event.pull_request.base.repo.full_name) == github.repository) }}
60+
echo 'github.repository =' ${{ github.repository }}
61+
echo 'github.ref =' ${{ github.ref }}
62+
63+
- name: "Rebuild datasets (fork)"
64+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
65+
run: |
66+
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --no-pull
6567
6668
- name: "Rebuild, commit and push datasets"
67-
if: github.ref != 'refs/heads/release'
69+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.ref != 'refs/heads/release' }}
6870
run: |
6971
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
7072
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7173
7274
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --push --repo="${GITHUB_REPOSITORY}"
7375
7476
- name: "Rebuild, commit, push and make a release"
75-
if: github.ref == 'refs/heads/release'
77+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.ref == 'refs/heads/release' }}
7678
run: |
7779
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
7880
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7981
8082
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --release --repo="${GITHUB_REPOSITORY}"
8183
84+
- name: "Install awscli"
85+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/release') }}
86+
run: |
87+
pushd /tmp >/dev/null
88+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
89+
unzip -oqq awscliv2.zip
90+
sudo ./aws/install --update
91+
popd >/dev/null
92+
aws --version
93+
8294
- name: "Deploy dataset server"
83-
if: ${{ endsWith(github.ref, '/master') || endsWith(github.ref, '/staging') || endsWith(github.ref, '/release') }}
95+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/release') }}
96+
env:
97+
DATA_AWS_S3_BUCKET: ${{ secrets.DATA_AWS_S3_BUCKET }}
98+
DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
99+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
100+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
101+
AWS_DEFAULT_REGION: us-east-2
84102
run: |
85103
./scripts/upload 'data_output/'
86104

0 commit comments

Comments
 (0)