1-[main] Validate, Add Version, Convert, Push to FTP #33
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
# Copy file to planeur.net FTP server | |
name: 2 - (main) Validate, Convert, Push to FTP | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow After the version has been added | |
workflow_run: | |
workflows: ["1 - Add version to france.txt"] | |
types: | |
- completed | |
# 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 | |
steps: | |
- name: 🚚 Get latest code | |
uses: actions/checkout@v3 | |
- id: validation | |
name: Validate france.txt + generate .geojson | |
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: ⚙️ Push .geojson to repo | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Automated Change | |
file_pattern: 'france.geojson' | |
outputs: | |
validation-output: ${{ steps.validation.outputs.parser_output }} | |
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...') | |
web-deploy: | |
name: 🎉 Upload files to FTP | |
runs-on: ubuntu-latest | |
needs: [check-validation] | |
if: | | |
always() && | |
contains(needs.validate-airspace.outputs.validation-output, 'Successfully parsed') | |
steps: | |
- name: 🚚 Get latest code | |
uses: actions/checkout@v3 | |
- 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 | |
convert-to-cub: | |
name: Convert france.txt to .cub | |
runs-on: ubuntu-latest | |
needs: [check-validation] | |
if: | | |
always() && | |
contains(needs.validate-airspace.outputs.validation-output, 'Successfully parsed') | |
steps: | |
- name: 🚚 Get latest code | |
uses: actions/checkout@v3 | |
- name: ⚙️ Convert to .cub and push to repo | |
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 | |
- name: ⚙️ Push .cub to repo | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Automated Change | |
file_pattern: 'france.cub' | |