Skip to content

1.3 - Create XCSoar _details.txt + version + zip #58

1.3 - Create XCSoar _details.txt + version + zip

1.3 - Create XCSoar _details.txt + version + zip #58

# Copy file to planeur.net FTP server
name: 1.3 - Create XCSoar _details.txt + version + zip
# Controls when the workflow will run
on:
# Triggers the workflow After the version has been added
workflow_run:
workflows: ["1.2 - Create .kmz", "2.1 - Convert to .cupx - champs_des_alpes.cup"]
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:
convert-to-xcsoar:
if: github.ref == 'refs/heads/main' && github.repository == 'planeur-net/outlanding'
name: create xcsoar details
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code for outlanding
uses: actions/checkout@v3
with:
path: ./outlanding
- name: 🚚 Get latest code for cup2xcsoar
uses: actions/checkout@v3
with:
repository: llauner/cup2xcsoar
token: ${{ secrets.ACCESS_TOKEN_CUP2KMZ }}
path: ./cup2xcsoar
ref: master
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Install dependencies
run: |
cd ./cup2xcsoar
- name: ⚙️ Create _details.txt
id: create_details
run: |
echo "### Create guide_aires_securite_details.txt"
cd ./cup2xcsoar
node ./cupToXCSoar.js ../outlanding/guide_aires_securite.cup ../outlanding/champs_des_alpes.cup
echo "### Copy _details to outlanding repo location"
cp ./guide_aires_securite_details.txt ../outlanding/
cp ./combined_guide+champs_details.txt ../outlanding/
- name: Set version
id: set_version
run: |
# Get information
cd ./outlanding
git log --pretty="%h %cI" -n1 -- guide_aires_securite.cup
versionInfo=$(git log --pretty="%h %cI" -n1 -- guide_aires_securite.cup)
# Remove first line if applicable
sed -i "$((grep -nm1 \"[version] ./guide_aires_securite_details.txt || echo 1000000000:) | cut -f 1 -d:) d" ./guide_aires_securite_details.txt
# Add version information
sed -i "2i $versionInfo" ./guide_aires_securite_details.txt
- name: Combine guide_aires_securite + champs_des_alpes
id: combine_guide_champs
run: |
cd ./outlanding
echo "Combine guide_aires_securite + champs_des_alpes"
sed '/-----Related Tasks-----/d' guide_aires_securite.cup > part1.cup
sed '/-----Related Tasks-----/d' champs_des_alpes.cup > part2.cup
# Remove versionInfo
sed -i "$((grep -nm1 \"version= ./part1.cup || echo 1000000000:) | cut -f 1 -d:) d" ./part1.cup
sed -i "$((grep -nm1 \"version= ./part2.cup || echo 1000000000:) | cut -f 1 -d:) d" ./part2.cup
# Remove header
sed -i '1d' part2.cup
# Concatenate files
cat part1.cup part2.cup > combined_guide+champs.cup
# Add versionInfo
export v1=$(git log --pretty="%h %cI" -n1 -- guide_aires_securite.cup)
export v2=$(git log --pretty="%h %cI" -n1 -- champs_des_alpes.cup)
export versionInfo=`echo [guide_aires_securite]$v1 + [champs_des_alpes]$v2`
echo $versionInfo
sed -i "2i \"version=\",,,,,,,,,,,\"$versionInfo\",," ./combined_guide+champs.cup
# Cleanup
rm part1.cup part2.cup
- name: Create ZIP for XCSoar folder
id: create_zip
run: |
echo "### Create ZIP to be copied to XCSoar folder"
cd ./outlanding
zip guide_aires_securite.xcsoar.zip guide_aires_securite.cup guide_aires_securite_details.txt Pics/*
echo "### Create combined_guide+champs ZIP file"
cp Pics_champs_des_alpes/* Pics/
zip combined_guide+champs.xcsoar.zip combined_guide+champs.cup combined_guide+champs_details.txt Pics/*
# Save commit message for future push
echo "LAST_COMMIT_MESSSAGE=`git log --format=%s -n 1 -- champs_des_alpes.cup`" >> $GITHUB_OUTPUT
- name: ⚙️ Push to repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./outlanding
commit_message: ${{ steps.create_zip.outputs.LAST_COMMIT_MESSSAGE }}
file_pattern: 'guide_aires_securite_details.txt guide_aires_securite.xcsoar.zip combined_guide+champs.cup combined_guide+champs_details.txt combined_guide+champs.xcsoar.zip'
- name: Trigger event for github pages update
uses: peter-evans/repository-dispatch@v2
with:
event-type: update-pages-event