Skip to content

Update PR on upstream changes #966

Update PR on upstream changes

Update PR on upstream changes #966

# copied from https://github.com/ubuntu/yaru/blob/master/.github/workflows/open-pr-on-changes.yaml
name: Update PR on upstream changes
on:
push:
paths:
- '.github/workflows/open-pr-on-changes.yaml'
schedule:
- cron: '8 0 * * *'
jobs:
refresh-upstream:
name: Check for upstream theme related changes
runs-on: ubuntu-latest
strategy:
matrix:
buildenv:
[
{
project: GNOME Shell,
repo: 'https://gitlab.gnome.org/GNOME/gnome-shell.git',
upstreambranch: main,
localbranch: gnome-shell,
projectdir: gnome-shell,
src: data/theme,
dest: adwaita/upstream/gnome-shell,
},
{
project: GTK2,
repo: 'https://gitlab.gnome.org/GNOME/gnome-themes-extra.git',
upstreambranch: master,
localbranch: gtk2,
projectdir: gnome-themes-extra,
src: themes/Adwaita-dark/gtk-2.0,
dest: adwaita/upstream/gtk-2.0-dark,
},
{
project: GTK4,
repo: 'https://gitlab.gnome.org/GNOME/libadwaita.git',
upstreambranch: main,
localbranch: gtk4,
projectdir: libadwaita,
src: src/stylesheet/_defaults.scss src/stylesheet/_palette.scss,
dest: adwaita/upstream/gtk-4.0/,
},
]
steps:
# Checkout code
- uses: actions/checkout@v4
- name: Download from ${{ matrix.buildenv.repo }}, on branch ${{ matrix.buildenv.upstreambranch }}
id: checknewupstream
run: |
hasModif="false"
pushd /tmp
git clone --branch ${UPSTEAM_BRANCH} --depth 1 ${UPSTREAM_REPO_URL}
popd
if [ ${DEST: -1} == '/' ]; then
mkdir -p ${DEST}
for src in ${SRC}; do
cp -a /tmp/${PROJECT_DIR}/${src} ${DEST}
done
else
rm -rf ${DEST}
cp -a /tmp/${PROJECT_DIR}/${SRC} ${DEST}
fi
MODIFIED=$(git status --porcelain)
if [ -n "$MODIFIED" ]; then
hasModif="true"
fi
echo "modified=${hasModif}" >> $GITHUB_OUTPUT
env:
UPSTREAM_REPO_URL: ${{ matrix.buildenv.repo }}
UPSTEAM_BRANCH: ${{ matrix.buildenv.upstreambranch }}
SRC: ${{ matrix.buildenv.src }}
DEST: ${{ matrix.buildenv.dest }}
PROJECT_DIR: ${{ matrix.buildenv.projectdir }}
- name: Create or update Pull Request
if: steps.checknewupstream.outputs.modified == 'true'
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'chore: new upstream snapshot for ${{ matrix.buildenv.project }}'
title: Auto update new upstream snapshot for ${{ matrix.buildenv.project }}
labels: automated pr, new upstream
body: '[New upstream ${{ matrix.buildenv.project }} changes](https://github.com/lonr/adwaita-one-dark/actions?query=workflow%3A%22Update+PR+on+upstream+changes%22) by GitHub Action'
branch: upstream-${{ matrix.buildenv.localbranch }}-update
token: ${{ secrets.GITHUB_TOKEN }}