@@ -31,20 +31,64 @@ 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 :
37+ - name : config
38+ id : config
39+ run : |
40+ echo 'is_fork=${{ (github.event_name == 'pull_request') && (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_OUTPUT
41+
42+ echo 'should_deploy=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/release' }}' >> $GITHUB_OUTPUT
43+
44+ echo 'is_release=${{ github.ref == 'refs/heads/release' }}' >> $GITHUB_OUTPUT
45+
46+ - name : " DEBUG"
47+ run : |
48+ set +x
49+
50+ echo is_fork=${{ steps.config.outputs.is_fork }}
51+ echo should_deploy=${{ steps.config.outputs.should_deploy }}
52+ echo is_release=${{ steps.config.outputs.is_release }}
53+
54+ echo '\n'
55+
56+ echo 'github.ref =' ${{ github.ref }}
57+ echo 'github.event_name =' ${{ github.event_name }}
58+ echo 'github.repository =' ${{ github.repository }}
59+
60+ echo '\n'
61+
62+ echo 'github.event.pull_request.head.repo.fork =' ${{ github.event.pull_request.head.repo.fork }}
63+ echo 'github.event.pull_request.head.repo.full_name =' ${{ github.event.pull_request.head.repo.full_name }}
64+
65+ echo '\n'
66+
67+ echo 'github.event.pull_request.base.repo.fork =' ${{ github.event.pull_request.base.repo.fork }}
68+ echo 'github.event.pull_request.base.repo.full_name =' ${{ github.event.pull_request.base.repo.full_name }}
69+
70+ echo '\n'
71+
72+ 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 }}
73+ 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 }}
74+ echo 'github.event_name == 'pull_request' && (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_name == 'pull_request' && (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)) }}
75+
76+ - name : " Checkout code (fork)"
77+ if : ${{ steps.config.outputs.is_fork == 'true' }}
78+ uses : actions/checkout@v4
79+ with :
80+ fetch-depth : 0 # Number of commits to fetch. 0 indicates all history for all branches and tags.
81+ fetch-tags : true # Whether to fetch tags, even if fetch-depth > 0.
82+ ref : ${{github.event.pull_request.head.ref}}
83+ repository : ${{github.event.pull_request.head.repo.full_name}}
84+
4285 - name : " Checkout code"
86+ if : ${{ steps.config.outputs.is_fork != 'true' }}
4387 uses : actions/checkout@v4
4488 with :
4589 fetch-depth : 0 # Number of commits to fetch. 0 indicates all history for all branches and tags.
4690 fetch-tags : true # Whether to fetch tags, even if fetch-depth > 0.
47- ref : ${{ github.event.pull_request.head.ref || github.ref_name }}
91+ ref : ${{ github.head_ref || github.ref }}
4892
4993 - name : " Install system dependencies"
5094 run : |
@@ -54,33 +98,45 @@ jobs:
5498 run : |
5599 pip3 install -r requirements.txt
56100
57- - name : " Install awscli"
101+ - name : " Rebuild datasets (fork)"
102+ if : ${{ steps.config.outputs.is_fork == 'true' }}
58103 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
104+ ./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --no-pull
65105
66- - name : " Rebuild, commit and push datasets"
67- if : github.ref != 'refs/heads/release'
106+ - name : " Rebuild, commit and push datasets (non-release branch) "
107+ if : ${{ steps.config.outputs.is_fork != 'true' && steps.config.outputs.is_release != 'true' }}
68108 run : |
69109 git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
70110 git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
71111
72112 ./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --push --repo="${GITHUB_REPOSITORY}"
73113
74- - name : " Rebuild, commit, push and make a release"
75- if : github.ref == 'refs/heads/release'
114+ - name : " Rebuild, commit, push and make a release (release branch) "
115+ if : ${{ steps.config.outputs.is_fork != 'true' && steps.config.outputs.is_release == 'true' }}
76116 run : |
77117 git config --global user.email "${{ secrets.BOT_GIT_USER_EMAIL }}"
78118 git config --global user.name "${{ secrets.BOT_GIT_USER_NAME }}"
79119
80120 ./scripts/rebuild --input-dir 'data/' --output-dir 'data_output/' --release --repo="${GITHUB_REPOSITORY}"
81121
122+ - name : " Install awscli"
123+ if : ${{ steps.config.outputs.is_fork != 'true' && steps.config.outputs.should_deploy == 'true' }}
124+ run : |
125+ pushd /tmp >/dev/null
126+ curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
127+ unzip -oqq awscliv2.zip
128+ sudo ./aws/install --update
129+ popd >/dev/null
130+ aws --version
131+
82132 - name : " Deploy dataset server"
83- if : ${{ endsWith(github.ref, '/master') || endsWith(github.ref, '/staging') || endsWith(github.ref, '/release') }}
133+ if : ${{ steps.config.outputs.is_fork != 'true' && steps.config.outputs.should_deploy == 'true' }}
134+ env :
135+ DATA_AWS_S3_BUCKET : ${{ secrets.DATA_AWS_S3_BUCKET }}
136+ DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID : ${{ secrets.DATA_AWS_CLOUDFRONT_DISTRIBUTION_ID }}
137+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
138+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
139+ AWS_DEFAULT_REGION : us-east-2
84140 run : |
85141 ./scripts/upload 'data_output/'
86142
0 commit comments