Implement workspace internal dependency updater (#262) #195
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
update-internal-dependencies: | |
name: Update internal dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Set up git | |
uses: ./.github/actions/setup-git | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.work | |
- name: Update submodules | |
uses: ./.github/actions/update-workspace-dependencies | |
with: | |
module: wsl-pro-service | |
- name: Detect modifications | |
shell: bash | |
id: check-diff | |
run: | | |
hasModif="false" | |
MODIFIED=$(git status --porcelain --untracked-files=no) | |
if [ -n "$MODIFIED" ]; then | |
hasModif="true" | |
fi | |
echo "modified=${hasModif}" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
if: steps.check-diff.outputs.modified == 'true' | |
with: | |
commit-message: Auto update internal dependencies | |
title: Auto update WSL-Pro-Service dependencies | |
labels: 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/update-internal-dependencies | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push branch | |
if: steps.check-diff.outputs.modified == 'true' | |
run: | | |
git push origin auto-updates/update-internal-dependencies:main |