-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto update workflow for manifest.
- Loading branch information
1 parent
c715f82
commit e85643c
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Check for updates | ||
|
||
on: | ||
schedule: # for scheduling to work this file must be in the default branch | ||
- cron: "0 * * * *" # run every hour | ||
workflow_dispatch: # can be manually dispatched under GitHub's "Actions" tab | ||
|
||
env: | ||
# email sets "github-actions[bot]" as commit author, see https://github.community/t/github-actions-bot-email-address/17204/6 | ||
GIT_USER_NAME: github-actions[bot] | ||
GIT_USER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | ||
FLATPAK_ID: com.artemis_rgb.Artemis | ||
|
||
jobs: | ||
flatpak-external-data-checker: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08 | ||
options: --privileged | ||
|
||
strategy: | ||
matrix: | ||
branch: [ main ] # list all branches to check | ||
|
||
steps: | ||
|
||
- name: Install Python and yq | ||
run: | | ||
python -m ensurepip --upgrade | ||
python -m pip install ruamel.yaml yq | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ matrix.branch }} | ||
submodules: 'true' | ||
|
||
- name: Check for Flatpak source updates via Flatpak External Data Checker | ||
uses: docker://ghcr.io/flathub/flatpak-external-data-checker:latest | ||
with: | ||
args: --edit-only ${{ env.FLATPAK_ID }}.yml | ||
|
||
- name: Attempt to update the Artemis git sources | ||
run: | | ||
./.github/scripts/update-manifest.py | ||
- name: Verify if git was updated | ||
id: is-updated | ||
run: | | ||
git status -s -uno | ||
[ -z "$(git status -s -uno)" ] || echo "updated=true" >> $GITHUB_OUTPUT | ||
- name: Generate dotnet sources | ||
if: steps.is-updated.outputs.updated | ||
run: | | ||
# Extract required information from the manifest | ||
MANIFEST_FILE="${FLATPAK_ID}.yml" | ||
echo "Parsing manifest file '$MANIFEST_FILE' to determine required Flatpak packages and ID..." | ||
RUNTIME=$(yq e '.runtime' "$MANIFEST_FILE") | ||
RUNTIME_VERSION=$(yq e '.["runtime-version"]' "$MANIFEST_FILE") | ||
SDK=$(yq e '.sdk' "$MANIFEST_FILE") | ||
SDK_EXTENSIONS=$(yq e '.["sdk-extensions"][]' "$MANIFEST_FILE" 2>/dev/null || echo "") | ||
if [ -z "$RUNTIME" ] || [ -z "$RUNTIME_VERSION" ] || [ -z "$SDK" ] || [ -z "$FLATPAK_ID" ]; then | ||
error "Failed to extract required fields (runtime, runtime-version, sdk, id) from manifest." | ||
fi | ||
REQUIRED_FLATPAK_PACKAGES=( | ||
"$RUNTIME//$RUNTIME_VERSION" | ||
"$SDK//$RUNTIME_VERSION" | ||
) | ||
# Add SDK extensions if any | ||
if [ -n "$SDK_EXTENSIONS" ]; then | ||
while IFS= read -r EXT; do | ||
REQUIRED_FLATPAK_PACKAGES+=("$EXT//$RUNTIME_VERSION") | ||
done <<< "$SDK_EXTENSIONS" | ||
fi | ||
# Function to check if a Flatpak package is installed | ||
is_flatpak_installed() { | ||
local package="$1" | ||
flatpak info "$package" &> /dev/null | ||
} | ||
# Install missing Flatpak packages | ||
for package in "${REQUIRED_FLATPAK_PACKAGES[@]}"; do | ||
if is_flatpak_installed "$package"; then | ||
echo "Flatpak package '$package' is already installed." | ||
else | ||
echo "Flatpak package '$package' is not installed. Installing..." | ||
flatpak install -y flathub "$package" || error "Failed to install $package" | ||
fi | ||
done | ||
./generate-sources.py | ||
- name: Reset Flatpak manifest to pre-modified state | ||
run: | | ||
git checkout -- ${FLATPAK_ID}.yml | ||
- name: Run the Artemis git source updates again | ||
run: | | ||
./.github/scripts/update-manifest.py | ||
- name: Run Flatpak External Data Checker again and Open PR | ||
uses: docker://ghcr.io/flathub/flatpak-external-data-checker:latest | ||
env: | ||
GIT_AUTHOR_NAME: Flatpak External Data Checker | ||
GIT_COMMITTER_NAME: Flatpak External Data Checker | ||
GIT_AUTHOR_EMAIL: ${{ env.GIT_USER_NAME }} | ||
GIT_COMMITTER_EMAIL: ${{ env.GIT_USER_EMAIL }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: --update --never-fork ${{ env.FLATPAK_ID }}.yml |