Skip to content

Commit 0615865

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

1 file changed

Lines changed: 36 additions & 16 deletions

File tree

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

Lines changed: 36 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,58 @@ 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+
set -x
55+
56+
echo 'github.event.pull_request.head.repo.fork =' ${{ github.event.pull_request.head.repo.fork }}
57+
echo 'github.event.pull_request.head.repo.full_name =' ${{ github.event.pull_request.head.repo.full_name }}
58+
echo 'github.event.pull_request.base.repo.full_name =' ${{ github.event.pull_request.base.repo.full_name }}
59+
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 }}
60+
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 }}
61+
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) }}
62+
echo 'github.repository =' ${{ github.repository }}
63+
echo 'github.ref =' ${{ github.ref }}
64+
65+
- name: "Rebuild datasets (fork)"
66+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
67+
run: |
68+
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --no-pull
6569
6670
- name: "Rebuild, commit and push datasets"
67-
if: github.ref != 'refs/heads/release'
71+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.ref != 'refs/heads/release' }}
6872
run: |
6973
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
7074
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7175
7276
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --push --repo="${GITHUB_REPOSITORY}"
7377
7478
- name: "Rebuild, commit, push and make a release"
75-
if: github.ref == 'refs/heads/release'
79+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.ref == 'refs/heads/release' }}
7680
run: |
7781
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
7882
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7983
8084
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --release --repo="${GITHUB_REPOSITORY}"
8185
86+
- name: "Install awscli"
87+
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') }}
88+
run: |
89+
pushd /tmp >/dev/null
90+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
91+
unzip -oqq awscliv2.zip
92+
sudo ./aws/install --update
93+
popd >/dev/null
94+
aws --version
95+
8296
- name: "Deploy dataset server"
83-
if: ${{ endsWith(github.ref, '/master') || endsWith(github.ref, '/staging') || endsWith(github.ref, '/release') }}
97+
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') }}
98+
env:
99+
DATA_AWS_S3_BUCKET: ${{ secrets.DATA_AWS_S3_BUCKET }}
100+
DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
101+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
102+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
103+
AWS_DEFAULT_REGION: us-east-2
84104
run: |
85105
./scripts/upload 'data_output/'
86106

0 commit comments

Comments
 (0)