-
Notifications
You must be signed in to change notification settings - Fork 9
44 lines (37 loc) · 1.45 KB
/
1-add-version-to-france-txt.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: 1 - Add version to france.txt
# 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:
jobs:
add-version:
if: ${{ github.ref == 'refs/heads/main' }}
# 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 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
# 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'