@@ -25,10 +25,9 @@ inputs:
2525 # Needed for 'create-comment' step
2626 plots :
2727 description : ' Plots to be shown in comment'
28- repo_private_key :
29- description : ' Private key to access the plots repo'
28+ validator_key :
29+ description : ' Private ssh key to access the validator repo'
3030 type : string
31-
3231 dev :
3332 description : ' Run in development mode'
3433 type : boolean
4544 # ----------------------------------------
4645 # 'run-self-hosted-validation' step
4746 # ----------------------------------------
47+ - name : General setup and checks
48+ run : |
49+ # Check if from fork
50+ if [ "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]; then
51+ echo "Running from fork."
52+ fork=true
53+ exit 1 # Not supported yet
54+ else
55+ echo "Running from main repository."
56+ fork=false
57+ fi
58+
59+ # Bot config
60+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+ git config --global user.name "github-actions[bot]"
62+
63+ shell : bash
64+
4865 - name : Run self-hosted validation
4966 if : ${{ inputs.step == 'run-self-hosted-validation' }}
5067 run : |
6279 # Fetch hash of main branch
6380 _hash_main=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
6481 "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.base_ref }}" | jq -r '.sha')
65-
82+
6683 # Fetch hash of feature branch (via PR number, also works for branches from forks)
6784 pr_details=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
6885 "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}")
@@ -89,11 +106,14 @@ runs:
89106 --config_file ${{ inputs.snakemake_config }} \
90107 --pre_command "${{ inputs.pre_command }}" \
91108 --main_command "ariadne_all"
109+
92110 shell : bash
93111
94112 # ----------------------------------------
95113 # 'create-comment' step
96114 # ----------------------------------------
115+
116+
97117 - name : Download artifacts
98118 if : ${{ inputs.step == 'create-comment' }}
99119 uses : actions/download-artifact@v4
@@ -104,6 +124,7 @@ runs:
104124 # Move artifacts to home directory
105125 mkdir $HOME/artifacts
106126 mv ./* $HOME/artifacts
127+
107128 shell : bash
108129
109130 - name : Get variables from artifacts
@@ -139,16 +160,19 @@ runs:
139160
140161 shell : bash
141162
142- - name : Checkout main repo
163+ - name : Checkout model repo
143164 if : ${{ inputs.step == 'create-comment' }}
144165 uses : actions/checkout@v4
145166 with :
146167 fetch-depth : 0
168+ path : model-repo
147169
148170 - name : Get variables from repo
149171 if : ${{ inputs.step == 'create-comment' }}
150172 id : env-variables-repo
151173 run : |
174+ cd $GITHUB_WORKSPACE/model-repo
175+
152176 # Get git diff of used snakemake config
153177 git_diff_config=$(git diff $HASH_MAIN $HASH_FEATURE -- ${{ inputs.snakemake_config }})
154178
@@ -168,18 +192,21 @@ runs:
168192
169193 shell : bash
170194
171- - name : Checkout plot repo
195+ - name : Checkout validator repo
172196 if : ${{ inputs.step == 'create-comment' }}
173197 uses : actions/checkout@v4
174198 with :
175199 repository : lkstrp/pypsa-validator
176200 ref : ${{ github.repository }}
177- ssh-key : ${{ inputs.repo_private_key }}
201+ ssh-key : ${{ inputs.validator_key }}
202+ path : validator-repo
178203
179204 - name : Upload relevant plots
180205 id : upload-plots
181206 if : ${{ inputs.step == 'create-comment' }}
182207 run : |
208+ cd $GITHUB_WORKSPACE/validator-repo
209+
183210 rm -rf _validation-images
184211 mkdir -p _validation-images/feature
185212 mkdir -p _validation-images/main
@@ -194,16 +221,13 @@ runs:
194221 cp -r "$HOME/artifacts/results (feature branch)/${PREFIX_FEATURE}/${plot}" "_validation-images/feature" || true # ignore if run failed
195222 done
196223
197- # Bot config
198- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
199- git config --global user.name "github-actions[bot]"
200-
201224 # Add plots to repo branch
202225 echo "Adding plots to repo branch"
203226 git add _validation-images
204227 git commit -m "[github-actions.ci] upload validation images to show in comment" || true # ignore if no changes
205228 git push origin ${{ github.repository }}
206229 echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
230+
207231 shell : bash
208232
209233 - name : Set env for comment script
@@ -212,11 +236,14 @@ runs:
212236 # This needs to be done in a separate step to ensure the output is available
213237 echo "PLOTS_HASH=${{ steps.upload-plots.outputs.COMMIT_ID }}" >> $GITHUB_ENV
214238 echo "PLOTS=${{ inputs.plots }}" >> $GITHUB_ENV
239+
215240 shell : bash
216241
217242 - name : Draft comment
218243 if : ${{ inputs.step == 'create-comment' }}
219244 run : |
245+ cd $GITHUB_WORKSPACE/validator-repo
246+
220247 # Get potential changes from main branch
221248 git fetch origin
222249 if [ "${{ inputs.dev }}" = true ]; then
@@ -239,7 +266,7 @@ runs:
239266
240267 # Draft comment
241268 # Note: The script uses many env variables. See the script for more details.
242- python draft_comment.py > comment.txt
269+ python draft_comment.py > $GITHUB_WORKSPACE/ comment.txt
243270
244271 shell : bash
245272
@@ -293,7 +320,7 @@ runs:
293320 with :
294321 script : |
295322 const fs = require('fs');
296- let comment = fs.readFileSync(' comment.txt' , 'utf8');
323+ const comment = fs.readFileSync(`${process.env.GITHUB_WORKSPACE}/ comment.txt` , 'utf8');
297324
298325 github.rest.issues.updateComment({
299326 owner: context.repo.owner,
0 commit comments