-
Notifications
You must be signed in to change notification settings - Fork 9
187 lines (154 loc) · 5.63 KB
/
1-validate-convert-push.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Copy file to planeur.net FTP server
name: 1-Validate_Add_Version_Convert_Push_to_FTP
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches:
- main
paths:
- 'france.txt'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# see: https://github.com/marketplace/actions/ftp-deployment
jobs:
validate-airspace:
name: Validate OpenAir france.txt
runs-on: ubuntu-latest
outputs:
validation-output: ${{ steps.validation.outputs.parser_output }}
commit-message-output: ${{ steps.get_commit_message.outputs.LAST_COMMIT_MESSSAGE }}
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
- name: Validate france.txt + generate .geojson
id: validation
run: |
echo "## Install openaip-openair-parser"
git clone https://github.com/openAIP/openaip-openair-parser.git
cd openaip-openair-parser
npm install
echo "## Validating ..."
rm ../france.geojson
SCRIPT_OUTPUT=$(node ./cli.js -f ../france.txt --validate --debug -E -o ../france.geojson)
SCRIPT_RC=$?
echo "parser_output=$SCRIPT_OUTPUT" >> $GITHUB_OUTPUT
- name: Get commit Message
id: get_commit_message
run: |
# Save commit message for future push
echo "LAST_COMMIT_MESSSAGE=`git log --format=%s -n 1 -- france.txt`" >> $GITHUB_OUTPUT
- name: ⚙️ Push .geojson to repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ${{ steps.get_commit_message.outputs.LAST_COMMIT_MESSSAGE }}
file_pattern: 'france.geojson'
check-validation:
name: Check Validation
runs-on: ubuntu-latest
needs: [validate-airspace]
steps:
- name: Display validation output
run: |
echo "Validation output="
echo ${{needs.validate-airspace.outputs.validation-output}}
- name: Check validation
if: |
always() &&
contains(needs.validate-airspace.outputs.validation-output, 'Error')
uses: actions/github-script@v3
with:
script: |
core.setFailed('Validation failed ! See Above step for details...')
add-version:
if: ${{ github.ref == 'refs/heads/main' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: [check-validation]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Clone this repo
uses: actions/checkout@v4
# Add version information to france.txt
- name: Get info, delete 1st line if applicable, add info
id: add_version
run: |
# Get information
git log --pretty="%h %cI" -n1 -- france.txt
versionInfo=$(git log --pretty="%h %cI" -n1 -- france.txt)
# Remove first line if applicable
sed -i "$((grep -nm1 *version= ./france.txt || echo 1000000000:) | cut -f 1 -d:) d" ./france.txt
# Add version information
sed -i "1i *version= $versionInfo" ./france.txt
git pull
# Save commit message for future push
echo "LAST_COMMIT_MESSSAGE=`git log --format=%s -n 1 -- france.txt`" >> $GITHUB_OUTPUT
# Push changes to repo
- name: Push changes into repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ${{ steps.add_version.outputs.LAST_COMMIT_MESSSAGE }}
file_pattern: 'france.txt'
convert-to-cub:
name: Convert france.txt to .cub
runs-on: ubuntu-latest
needs: [add-version]
if: |
always() &&
contains(needs.validate-airspace.outputs.validation-output, 'Successfully parsed')
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
- name: ⚙️ Convert to .cub and push to repo
id: convert_to_cub
run: |
echo "Creating new .cub file"
chmod +x ./bin/openair2cub
./bin/openair2cub france.txt
# push to repo
echo "Pulling latest version before push..."
git pull
# Save commit message for future push
echo "LAST_COMMIT_MESSSAGE=`git log --format=%s -n 1 -- france.txt`" >> $GITHUB_OUTPUT
- name: ⚙️ Push .cub to repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ${{ steps.convert_to_cub.outputs.LAST_COMMIT_MESSSAGE }}
file_pattern: 'france.cub'
publish-pages:
name: Pyublish pages to github pages
runs-on: ubuntu-latest
needs: [convert-to-cub]
steps:
- name: Trigger event for github pages update
uses: peter-evans/repository-dispatch@v2
with:
event-type: update-pages-event
web-deploy:
name: 🎉 Upload files to FTP
runs-on: ubuntu-latest
needs: [convert-to-cub]
if: |
always() &&
contains(needs.validate-airspace.outputs.validation-output, 'Successfully parsed')
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
- name: 📂 Sync files
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: "./"
server-dir: "./"
exclude: |
**/.git*
**/.git*/**
**/bin/**
france.cub
france.geojson
README.md
dry-run: false