Skip to content

Generate updated ZSM branch #23

Generate updated ZSM branch

Generate updated ZSM branch #23

name: Generate updated ZSM branch
on:
workflow_dispatch:
inputs:
ZSM_URL:
description: 'URL to the ZSM .kml file'
required: true
default: 'https://www.stac.aviation-civile.gouv.fr/sites/default/files/france_1.kml'
jobs:
Download-Convert-ZSM-File:
name: Download and convert ZSM file
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
with:
path: 'airspace'
- name: Compute variables
id: variables
run: |
echo "::set-output name=date::$(date +'%Y-%m-%d-%H:%m:%S')"
echo "::set-output name=filename::autogenerated/$(date +'%Y-%m-%d-%H-%m-%S')_zsm_openair.txt"
echo "::set-output name=branch_name::autogenerated/$(date +'%Y-%m-%d-%H-%m-%S')_zsm_openair"
- name: Download and convert ZSM file
id: download-convert
run: |
echo "## Install openaip-openair-parser"
git clone https://github.com/llauner/kml2OpenAir.git
cd kml2OpenAir
npm install
echo "## Remove old zsm files ..."
rm -f ../airspace/autogenerated/*_zsm_openair.txt
echo "## Downloading and converting kmlfile ...: ${{ github.event.inputs.ZSM_URL }}"
node ./main.js ${{ github.event.inputs.ZSM_URL }} ../airspace/${{ steps.variables.outputs.filename }}
- name: Insert new ZSM
run: |
cd airspace
echo "## Remove old ZSM entries from france.txt ..."
sed -i '/\* ### ZSM start ###/,/\* ### ZSM stop ###/{//!d}' france.txt
echo "## Insert new ZSM entries ..."
sed -i '/\* ### ZSM start ###/r ${{ steps.variables.outputs.filename }}' france.txt
- name: ⚙️ Push .geojson to repo
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Add ZSM file for ${{ steps.variables.outputs.date }}"
repository: ./airspace
file_pattern: '${{ steps.variables.outputs.filename }} autogenerated/*_zsm_openair.txt france.txt'
create_branch: true
branch: ${{ steps.variables.outputs.branch_name }}
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v6
# with:
# title: "Add ZSM file for ${{ steps.variables.outputs.date }}"
# commit-message: "Add ZSM file for ${{ steps.variables.outputs.date }}"
# path: ./airspace
# add-paths: |
# ${{ steps.variables.outputs.filename }}
# *_zsm_openair.txt
# france.txt
# base: main
# branch: ${{ steps.variables.outputs.branch_name }}
# body: "This PR adds a new ZSM file for the date ${{ steps.variables.outputs.date }}."