Merge pull request #67 from planeur-net/feature/fix_r119 #18
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: 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 |