-
Notifications
You must be signed in to change notification settings - Fork 129
123 lines (100 loc) · 4 KB
/
merge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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@v4
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install klayout SiEPIC siepic_ebeam_pdk
python -m pip install --upgrade SiEPIC
- 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.oas EBeam.txt"
IFS=' '
mkdir -p merge_output
for file in $output_files; do
cp "/home/runner/work/openEBL-2024-02/openEBL-2024-02/merge/$file" merge_output/
done
- name: upload merge artifact
uses: actions/upload-artifact@v4
id: artifact-upload
with:
name: merge-files
path: merge_output/
- name: add vars needed for merge artifact url to a txt file
run: |
IFS='/' read -ra REPO <<< "$GITHUB_REPOSITORY"
OWNER="${REPO[0]}"
REPO_NAME="${REPO[1]}"
RUN_ID=${{ github.run_id }}
ARTIFACT_ID=${{ steps.artifact-upload.outputs.artifact-id }}
# add vars to txt file
echo "$ARTIFACT_ID" > url_info.txt
echo "$RUN_ID" >> url_info.txt
echo "$OWNER" >> url_info.txt
echo "$REPO_NAME" >> url_info.txt
- name: upload txt file as an artifact
uses: actions/upload-artifact@v4
with:
name: url-info
path: url_info.txt
# seperate job needed so we can check out and change code from gh-pages branch
update-url:
runs-on: ubuntu-latest
needs: merge
steps:
- name: checkout repo content
uses: actions/checkout@v2
with:
ref: gh-pages
- name: download url-info artifact
uses: actions/download-artifact@v4
with:
name: url-info
path: .
- name: get vars from url_info.txt file
run: |
ARTIFACT_ID=$(head -1 url_info.txt)
RUN_ID=$(sed -n '2p' url_info.txt)
OWNER=$(sed -n '3p' url_info.txt)
REPO_NAME=$(sed -n '4p' url_info.txt)
echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV
echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV
echo "OWNER=$OWNER" >> $GITHUB_ENV
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
- name: delete url-info artifact
uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: url-info
- name: update index.html with new merge artifact link
run: |
echo "New artifact URL: https://github.com/$OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID"
sed -i 's|URL=https://github.com/'"$OWNER"'/'"$REPO_NAME"'/actions/runs/.*|URL=https://github.com/'"$OWNER"'/'"$REPO_NAME"'/actions/runs/'"$RUN_ID"'/artifacts/'"$ARTIFACT_ID"'">|' index.html
sed -i 's|href="https://github.com/'"$OWNER"'/'"$REPO_NAME"'/actions/runs/.*|href="https://github.com/'"$OWNER"'/'"$REPO_NAME"'/actions/runs/'"$RUN_ID"'/artifacts/'"$ARTIFACT_ID"'">|' index.html
# merge script always runs on any PR, the if statement ensures link is only updated after a PR is merged into SiEPIC
- name: push changes to gh-pages branch
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add index.html
git commit -m "Update index.html to redirect to new merge artifact url"
git push
if: ${{ github.repository_owner == 'SiEPIC'}}