-
Notifications
You must be signed in to change notification settings - Fork 6
118 lines (110 loc) · 3.8 KB
/
auto-updates.yaml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Update translations and documentation
on:
push:
branches:
- main
paths-ignore:
- '**/README.md'
- '**/debian/control'
- '**/po/*'
jobs:
update-po:
name: Update po files
runs-on: ubuntu-latest
env:
subprojects: windows-agent wsl-pro-service
steps:
- name: Install dependencies
run: |
sudo DEBIAN_FRONTEND=noninteractive apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y gettext git
- uses: actions/checkout@v4
name: Check out repo
with:
ref: main
- uses: actions/setup-go@v4
with:
go-version-file: common/go.mod
- name: Set up git
# This step needs to be done so that the private repo dependencies can be downloaded
uses: ./.github/actions/setup-git
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check po files
id: checkpo
run: |
set -eu
hasModif="false"
for subproject in ${{ env.subprojects }} ; do
go generate "${subproject}/generate/generate-locales.go"
done
# Exclude line diffs only
MODIFIED=$(git difftool -y -x "diff -Nup -I '^#: '" "*/po/*")
if [ -n "$MODIFIED" ]; then
hasModif="true"
fi
echo "modified=${hasModif}" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.checkpo.outputs.modified == 'true'
uses: peter-evans/create-pull-request@v5
with:
commit-message: Auto update po files
title: Auto update po files
labels: po, automated pr
body: "[Auto-generated pull request](https://github.com/canonical/ubuntu-pro-for-windows/actions/workflows/auto-updates.yaml) by GitHub Action"
branch: auto-updates/locales
token: ${{ secrets.GITHUB_TOKEN }}
- name: Push branch
if: steps.checkpo.outputs.modified == 'true'
run: |
git push origin auto-updates/locales:main
update-readme-cli-ref:
name: Update readme and CLI ref files
runs-on: ubuntu-latest
needs: update-po
env:
subprojects: windows-agent wsl-pro-service
steps:
- name: Install dependencies
run: |
sudo DEBIAN_FRONTEND=noninteractive apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y git
- uses: actions/checkout@v4
name: Check out repository
with:
ref: main
- name: Set up git
uses: ./.github/actions/setup-git
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v4
name: Set up Go
with:
go-version-file: go.work
- name: Check README file
id: check-readme
run: |
set -eu
for subproject in ${{ env.subprojects }} ; do
go generate "${subproject}/generate/generate-docs.go"
done
hasModif="false"
MODIFIED=$(git status --porcelain --untracked-files=no)
if [ -n "$MODIFIED" ]; then
hasModif="true"
fi
echo "modified=${hasModif}" >> $GITHUB_OUTPUT
- uses: peter-evans/create-pull-request@v5
name: Create Pull Request
if: steps.check-readme.outputs.modified == 'true'
with:
commit-message: Auto update readme files
title: Auto update readme files
labels: readme, automated pr
body: "[Auto-generated pull request](https://github.com/canonical/ubuntu-pro-for-windows/actions/workflows/auto-updates.yaml) by GitHub Action"
branch: auto-updates/readme-cli-ref
token: ${{ secrets.GITHUB_TOKEN }}
- name: Push branch
if: steps.check-readme.outputs.modified == 'true'
run: |
git push origin auto-updates/readme-cli-ref:main