Run Merge Script #301
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Merge Script | |
on: | |
workflow_dispatch: | |
# run after layout verification | |
workflow_run: | |
workflows: ["Run Layout Verification"] | |
types: | |
- completed | |
jobs: | |
merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repo content | |
uses: actions/checkout@v2 | |
# can also specify python version if needed | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: install python packages | |
run: | | |
#python -m pip install --upgrade pip | |
pip install klayout SiEPIC pandas | |
# pip install siepic_ebeam_pdk | |
- name: run merge script | |
run: | | |
python merge/EBeam_merge.py | |
- name: move merge output files to new folder | |
run: | | |
#output_files="EBeam.gds EBeam.oas EBeam.txt EBeam.coords" | |
output_files="EBeam_Si_Heaters.oas EBeam_Si_Heaters.txt" | |
IFS=' ' | |
mkdir -p merge_output | |
for file in $output_files; do | |
cp "merge/$file" merge_output/ | |
done | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
id: artifact-upload | |
with: | |
name: merge-files | |
path: merge_output/ | |
- name: get artifact url | |
run: | | |
IFS='/' read -ra REPO <<< "$GITHUB_REPOSITORY" | |
OWNER="${REPO[0]}" | |
REPO_NAME="${REPO[1]}" | |
echo "Owner: $OWNER" | |
echo "Repository: $REPO_NAME" | |
RUN_ID=${{ github.run_id }} | |
ARTIFACT_ID=${{ steps.artifact-upload.outputs.artifact-id }} | |
ARTIFACT_URL="https://github.com/$OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID" | |
echo "Artifact URL: $ARTIFACT_URL" | |
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV | |
echo "OWNER=$OWNER" >> $GITHUB_ENV | |
- name: update url in runner README | |
run: | | |
# pull, in case there were changes since the start of this action | |
git pull | |
start_delim="<!-- start-link -->" | |
end_delim="<!-- end-link -->" | |
# remove current URL | |
sed -i "/$start_delim/,/$end_delim/d" README.md | |
# add new URL | |
printf "$start_delim\n$ARTIFACT_URL\n$end_delim\n" >> README.md | |
# merge script always runs on any PR, this ensures link is only updated after a PR is merged into SiEPIC | |
- name: commit and push changes to README if we are in SiEPIC repo | |
run: | | |
git diff | |
git config --local user.email "${{ github.actor }}@users.noreply.github.com" | |
git config --local user.name "${{ github.actor }}" | |
git add README.md | |
git commit -m "update README with new artifact url $ARTIFACT_URL" | |
git push | |
if: ${{ env.OWNER == 'SiEPIC'}} | |
- name: Create comment | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const ARTIFACT_URL = process.env.ARTIFACT_URL; | |
const commentBody = ` | |
### Draft merge: | |
Thank you for submitting your design. | |
Please download the merged layout and confirm (by responding in a Comment below) that your layout is correctly merged: | |
${ARTIFACT_URL} | |
Thank you! | |
`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody | |
}); | |
if: ${{ github.event.pull_request_target.opened || github.event.pull_request_target.synchronize || github.event.pull_request_target.reopened }} | |
# github.event.pull_request.merged == true |