Skip to content

Force latest as updated outside github #39

Force latest as updated outside github

Force latest as updated outside github #39

# Copy file to planeur.net FTP server
name: 1-[main] 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
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...')
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@v3
# Add version information to france.txt
- name: Get info, delete 1st line if applicable, add info
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
# Push changes to repo
- name: Push changes into repo
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automated Change
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@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'
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@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