Skip to content

2 - Add version to champs_des_alpes #33

2 - Add version to champs_des_alpes

2 - Add version to champs_des_alpes #33

name: 2 - Add version to champs_des_alpes
# 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:
- 'champs_des_alpes.cup'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
get-info:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Add version information to guide_aires_securite.cup
- name: Get info
id: get-info
run: |
echo "This was executed !!"
echo ${{ github.ref }}
echo ${{ github.repository }}
add-version:
if: github.ref == 'refs/heads/main' && github.repository == 'planeur-net/outlanding'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# 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 champs_des_alpes.cup
- name: Get info, delete 1st line if applicable, add info
id: set_version
run: |
# Get information
git log --pretty="%h %cI" -n1 -- champs_des_alpes.cup
versionInfo=$(git log --pretty="%h %cI" -n1 -- champs_des_alpes.cup)
# Remove first line if applicable
sed -i "$((grep -nm1 \"version= ./champs_des_alpes.cup || echo 1000000000:) | cut -f 1 -d:) d" ./champs_des_alpes.cup
# Add version information
sed -i "2i \"version=\",,,,,,,,,,,\"$versionInfo\",," ./champs_des_alpes.cup
# Save commit message for future push
echo "LAST_COMMIT_MESSSAGE=`git log --format=%s -n 1 -- champs_des_alpes.cup`" >> $GITHUB_OUTPUT
# Push changes to repo
- name: Push changes into repo
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: ${{ steps.set_version.outputs.LAST_COMMIT_MESSSAGE }}
file_pattern: 'champs_des_alpes.cup'