update action, test #1
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: Merge complete | ||
# merge the layout after the pull request is approved | ||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
jobs: | ||
approved: | ||
if: github.event.review.state == 'APPROVED' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo content | ||
uses: actions/checkout@v3 | ||
with: | ||
# https://github.com/MestreLion/git-tools?tab=readme-ov-file#git-restore-mtime | ||
fetch-depth: 0 | ||
- name: Restore original modification time of files based on the date of the most recent commit | ||
uses: chetan/git-restore-mtime-action@v2 | ||
- name: setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
- name: install Python packages | ||
run: | | ||
pip install klayout SiEPIC siepic_ebeam_pdk pandas | ||
- name: run merge script | ||
run: | | ||
python merge/EBeam_merge.py | ||
- name: move merge output files to new folder | ||
run: | | ||
output_files="EBeam.oas EBeam.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: | | ||
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 | ||
# after a PR is merged into SiEPIC | ||
- name: commit and push changes to README if we are in SiEPIC repo | ||
run: | | ||
git pull origin main | ||
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: github.repository_owner == 'SiEPIC' | ||
- name: Create comment | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const missingFilesList = process.env.missing_files_list; | ||
const commentBody = ` | ||
### Layout merged: | ||
Thank you for submitting your design. | ||
Your design has been accepted and merged! | ||
Please download the merged layout and double-check 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 | ||
}); | ||