Skip to content

Generate updated ZSM branch #8

Generate updated ZSM branch

Generate updated ZSM branch #8

name: Generate ZSM Pull Request
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: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d-%H:%m:%S')"
- name: Compute output filename
id: output_filename
run: echo "::set-output filename=../airspace/${{ steps.date.outputs.date }}_zsm_openair.txt"
- name: Download and convert ZSM file
id: download-convert
run: |
current_date=${{ steps.date.outputs.date }}
echo "## Install openaip-openair-parser"
git clone https://github.com/llauner/kml2OpenAir.git
cd kml2OpenAir
npm install
echo "## Downloading and converting kmlfile ...: ${{ github.event.inputs.ZSM_URL }}"
node ./main.js ${{ github.event.inputs.ZSM_URL }} ${{ steps.output_filename.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.output_filename.outputs.filename }}' france.txt
cd ../airspace
git pull
- name: ⚙️ Push .kml + .kmz to repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./airspace
commit_message: "Add ZSM file for ${{ steps.date.outputs.date }}"
branch: autogenerated/zsm-${{ steps.date.outputs.date }}
create_branch: true
file_pattern: ${{ steps.output_filename.outputs.filename }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
title: "Add ZSM file for ${{ steps.date.outputs.date }}"
branch: "autogenerated/zsm-${{ steps.date.outputs.date }}"
body: "This PR adds a new ZSM file for the date ${{ steps.date.outputs.date }}."