-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (127 loc) · 5.11 KB
/
pull-request.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Handle Pull Request
on:
pull_request:
types: [opened, ready_for_review]
env:
SITU_OWNER: "ronyan"
SITU_REPOSITORY: "VATCANSitu"
jobs:
prepare:
name: "🏗️ Prepare"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get latest AeroNav data provider
run: curl -s http://files.aero-nav.com/AeroNav_CZWG_by_Aerosoft_NavDataPro.txt | grep -A3 'SECTOR_NAME:CZWG NAV_Data' > SectorProvider.txt
- id: variables
name: Export variables
run: |
echo "data_url=$( sed -n 's/SECTOR_URL://p' SectorProvider.txt )" >> $GITHUB_ENV
echo "airac_version=$( grep -Po '(?<=SECTOR_VERSION:([0-9]{14})-).[[:digit:]]+(?=-)' SectorProvider.txt | cut -c 1-4 )" >> $GITHUB_ENV
echo "airac_update_version=$( grep -Po '(?<=SECTOR_VERSION:([0-9]{14})-).[[:digit:]]+(?=-)' SectorProvider.txt | cut -c 5-6 )" >> $GITHUB_ENV
echo "situ_urls=$( cd $GITHUB_WORKSPACE/.github/workflows && python3 -c 'import os; import functions; print(functions.get_latest_release_download(os.environ["SITU_OWNER"], os.environ["SITU_REPOSITORY"]))' )" >> $GITHUB_ENV
outputs:
release_tag: ${{ steps.tag-name.outputs.tag }}
data_url: ${{ env.data_url }}
airac_version: ${{ env.airac_version }}
airac_update_version: ${{ env.airac_update_version }}
situ_urls: ${{ env.situ_urls }}
update-navdata:
name: "🔃 Update NavData"
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download and extract sector data
run: |
curl -s -H "User-Agent: EuroScope" -o temp.7z ${{ needs.prepare.outputs.data_url }}
7z x temp.7z -y -o /tmp/sector-data
rm temp.7z
- name: Update NavData folder
run: |
cp -TR /tmp/sector-data/CZWG/ICAO CZWG/ICAO
cp -TR /tmp/sector-data/CZWG/NavData CZWG/NavData
- name: Prepare and insert new data
run: |
# Update .sct file
sed -n "/\[VOR\]/,/^\s*$/p" /tmp/sector-data/*.sct >> *.sct
sed -n "/\[NDB\]/,/^\s*$/p" /tmp/sector-data/*.sct >> *.sct
sed -n "/\[FIXES\]/,/^\s*$/p" /tmp/sector-data/*.sct >> *.sct
sed -n "/\[HIGH AIRWAY\]/,/^\s*$/p" /tmp/sector-data/*.sct >> *.sct
# Update ese
echo -e "\n[SIDSSTARS]" >> *.ese
sed -n '/^\(SID:\|STAR:\)/p' /tmp/sector-data/*.ese >> *.ese
# Update name in [INFO]
gawk -i inplace '/\[INFO\]/{ n=NR+1 } NR==n{ $0="CZWG ${{ needs.prepare.outputs.airac_version }} ${{ needs.prepare.outputs.release_tag }}" }1' *.sct
- name: Upload sector data
uses: actions/upload-artifact@v4
with:
name: sector-data
path: |
./
!.git
latest-situ-release:
name: "💾 Save latest VATCAN Situ release"
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v4
- name: Get latest release
working-directory: ${{ runner.temp }}
run: |
wget ${{ needs.prepare.outputs.situ_urls }}
mv *.dll VATCANSitu-latest.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: vatcan-situ-latest
path: ${{ runner.temp }}/VATCANSitu-latest.dll
package:
name: "📦 Package"
if: ${{ always() && needs.update-navdata.result != 'failure' && needs.latest-situ-release.result != 'failure' }}
needs: [prepare, update-navdata, latest-situ-release]
runs-on: ubuntu-latest
env:
AIRAC_VERSION: ${{ needs.prepare.outputs.airac_version }}
AIRAC_UPDATE_VERSION: ${{ needs.prepare.outputs.airac_update_version }}
RELEASE_TAG: ${{ needs.prepare.outputs.release_tag}}
steps:
- uses: actions/checkout@v4
- name: Get sector data
uses: actions/download-artifact@v4
with:
name: sector-data
- name: Get latest VATCAN Situ
uses: actions/download-artifact@v4
with:
name: vatcan-situ-latest
path: CZWG\Plugins
- name: Remove extra directories
run: |
rm -rf .git
rm -rf .github
- name: Compress files
env:
VERSION: ${{ env.AIRAC_VERSION }}_${{ env.AIRAC_UPDATE_VERSION }}_${{ env.RELEASE_TAG }}
run: |
mv *.ese CZWG_Full_"$VERSION".ese && mv *.sct CZWG_Full_"$VERSION".sct
# Insert 'sector' line into profile
sed -i "1s/^/Settings sector \\CZWG_Full_$VERSION.sct\n/" *.prf
zip -r ${{ runner.temp }}/CZWG_Full_"$VERSION".zip .
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: Testing File
path: ${{ runner.temp }}/CZWG_Full_${{ env.AIRAC_VERSION }}_${{ env.AIRAC_UPDATE_VERSION }}_${{ env.RELEASE_TAG }}.zip
cleanup:
name: "🧹 Cleanup"
if: ${{ always() }}
needs: [package]
runs-on: ubuntu-latest
steps:
- name: Clean artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
sector-data
vatcan-situ-latest