Skip to content

Commit 95a53e0

Browse files
chore: fix ci when a pr is submitted from a fork
1 parent 9170a53 commit 95a53e0

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

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

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- staging
66
- release
77
pull_request:
8+
pull_request_target:
89
repository_dispatch:
910
types: build-and-deploy
1011
workflow_dispatch:
@@ -25,26 +26,27 @@ jobs:
2526
build-and-deploy-datasets:
2627
runs-on: ubuntu-20.04
2728

28-
environment:
29-
name: ${{ github.ref }}
30-
3129
env:
3230
VERBOSE: 0
3331
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
39-
GH_TOKEN: ${{ github.token }}
4032

4133
steps:
4234
- name: "Checkout code"
35+
# if: github.event.pull_request.head.repo.full_name == github.repository
4336
uses: actions/checkout@v3
4437
with:
4538
fetch-depth: 0
4639
submodules: true
4740

41+
# - name: "Checkout code (fork)"
42+
# if: github.event.pull_request.head.repo.full_name != github.repository
43+
# uses: actions/checkout@v3
44+
# with:
45+
# fetch-depth: 0
46+
# submodules: true
47+
# ref: ${{github.event.pull_request.head.ref}}
48+
# repository: ${{github.event.pull_request.head.repo.full_name}}
49+
4850
- name: "Install system dependencies"
4951
run: |
5052
sudo apt-get install brotli pigz parallel python3 rename --yes -qq >/dev/null
@@ -53,44 +55,46 @@ jobs:
5355
run: |
5456
pip3 install -r requirements.txt
5557
56-
- name: "Install awscli"
58+
- name: "Rebuild, commit and push datasets (from a fork)"
59+
if: github.event.pull_request.head.repo.full_name != github.repository
5760
run: |
58-
pushd /tmp >/dev/null
59-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
60-
unzip -oqq awscliv2.zip
61-
sudo ./aws/install --update
62-
popd >/dev/null
63-
aws --version
61+
git config --global user.email "nextstrain-bot-from-fork"
62+
git config --global user.name "[email protected]"
6463
65-
- name: "Rebuild, commit and push datasets"
64+
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --no-pull --push --repo="${GITHUB_REPOSITORY}"
65+
66+
- name: "Rebuild, commit and push (non-release branch)"
6667
if: github.ref != 'refs/heads/release'
6768
run: |
6869
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
6970
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7071
7172
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --push --repo="${GITHUB_REPOSITORY}"
7273
73-
- name: "Rebuild, commit, push and make a release"
74+
- name: "Rebuild, commit, push and make a release (release branch)"
7475
if: github.ref == 'refs/heads/release'
76+
env:
77+
GH_TOKEN: ${{ github.token }}
7578
run: |
7679
git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
7780
git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
7881
7982
./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --release --repo="${GITHUB_REPOSITORY}"
8083
8184
- name: "Deploy dataset server"
82-
if: ${{ endsWith(github.ref, '/master') || endsWith(github.ref, '/staging') || endsWith(github.ref, '/release') }}
85+
if: ${{ (github.event.pull_request.head.repo.full_name == github.repository) && (endsWith(github.ref, '/master') || endsWith(github.ref, '/staging') || endsWith(github.ref, '/release')) }}
86+
env:
87+
DATA_AWS_S3_BUCKET: ${{ secrets.DATA_AWS_S3_BUCKET }}
88+
DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
89+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
90+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
91+
AWS_DEFAULT_REGION: us-east-2
8392
run: |
84-
./scripts/upload 'data_output/'
85-
86-
- name: "Upload build artifacts: dataset server"
87-
uses: actions/upload-artifact@v3
88-
with:
89-
name: server
90-
path: ./data_output/*
93+
pushd /tmp >/dev/null
94+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
95+
unzip -oqq awscliv2.zip
96+
sudo ./aws/install --update
97+
popd >/dev/null
98+
aws --version
9199
92-
- name: "Upload build artifacts: zip archives"
93-
uses: actions/upload-artifact@v3
94-
with:
95-
name: zips
96-
path: ./data_temp/*
100+
./scripts/upload 'data_output/'

0 commit comments

Comments
 (0)