Merge pull request #254 from xnox/port-to-embed #185
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 master branch automatically | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- po/* | |
- README.md | |
env: | |
goversion: '1.20' | |
jobs: | |
update-po: | |
name: Update po files | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
- name: Install dependencies, including git for checkout | |
run: | | |
apt update | |
DEBIAN_FRONTEND=noninteractive apt install -y gettext git | |
# Checkout code with git | |
- uses: actions/checkout@v3 | |
with: | |
ref: master | |
# As per https://github.com/actions/runner/issues/2033#issuecomment-1204205989 | |
- name: Set ownership | |
run: | | |
# this is to fix GIT not liking owner of the checkout dir | |
chown -R $(id -u):$(id -g) $PWD | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.goversion }} | |
# Update po if needed | |
- name: Check po files | |
id: checkpo | |
run: | | |
hasModif="false" | |
go generate ./internal/i18n/ | |
# Exclude line diffs only | |
MODIFIED=$(git difftool -y -x "diff -Nup -I '^#: '" po/) | |
if [ -n "$MODIFIED" ]; then | |
hasModif="true" | |
fi | |
echo "modified=${hasModif}" >> $GITHUB_ENV | |
- name: Create Pull Request | |
if: ${{ env.modified == 'true' }} | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
commit-message: Auto update po files | |
title: Auto update po files | |
labels: po, automated pr | |
body: "[Auto-generated pull request](https://github.com/ubuntu/zsys/actions?query=workflow%3A%22Update+master+branch+automatically%22) by GitHub Action" | |
branch: auto-update-po | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push branch | |
if: ${{ env.modified == 'true' }} | |
run: | | |
git push origin auto-update-po:master | |
update-readme: | |
name: Update readme file | |
# This should just be "after", but we don't want the 2 jobs to push at the same time | |
needs: update-po | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
- name: Enable proposed | |
run: | | |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list | |
cat <<EOF >/etc/apt/preferences.d/proposed.pref | |
Package: * | |
Pin: release a=*-proposed | |
Pin-Priority: 500 | |
EOF | |
- name: Install dependencies, including git for checkout | |
run: | | |
apt update | |
DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install libzfslinux-dev git gcc | |
# Checkout code with git | |
- uses: actions/checkout@v3 | |
with: | |
ref: master | |
# As per https://github.com/actions/runner/issues/2033#issuecomment-1204205989 | |
- name: Set ownership | |
run: | | |
# this is to fix GIT not liking owner of the checkout dir | |
chown -R $(id -u):$(id -g) $PWD | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.goversion }} | |
# Try updating README | |
- name: Check README file | |
id: checkreadme | |
run: | | |
hasModif="false" | |
cd cmd/zsysd | |
go run ./generate-mancomp.go cobracompletion.go completion.go update-readme | |
MODIFIED=$(git status --porcelain --untracked-files=no) | |
if [ -n "$MODIFIED" ]; then | |
hasModif="true" | |
fi | |
echo "modified=${hasModif}" >> $GITHUB_ENV | |
- name: Create Pull Request | |
if: ${{ env.modified == 'true' }} | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
commit-message: Auto update readme files | |
title: Auto update readme files | |
labels: readme, automated pr | |
body: "[Auto-generated pull request](https://github.com/ubuntu/zsys/actions?query=workflow%3A%22Update+master+branch+automatically%22) by GitHub Action" | |
branch: auto-update-readme | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push branch | |
if: ${{ env.modified == 'true' }} | |
run: | | |
git push origin auto-update-readme:master |