mirror of
https://github.com/RetroDECK/components-template.git
synced 2024-11-23 19:55:38 +00:00
Repo shaping
This commit is contained in:
parent
d774c2ee45
commit
0a0dc5bbab
101
.github/workflows/pr_from_upstream.yml
vendored
Normal file
101
.github/workflows/pr_from_upstream.yml
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
name: "Sync with Upstream and Create PR"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
sync-upstream:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
fetch-depth: 0 # Retrieve full history to allow merging
|
||||
|
||||
- name: Set default values for UPSTREAM_REPO and TARGET_BRANCH if not set
|
||||
run: |
|
||||
# Use the current repository name if UPSTREAM_REPO is not set
|
||||
: "${UPSTREAM_REPO:=${{ github.repository }} }"
|
||||
: "${TARGET_BRANCH:=master}"
|
||||
|
||||
# Format the repository name for flathub
|
||||
UPSTREAM_REPO="https://github.com/flathub/${UPSTREAM_REPO}"
|
||||
|
||||
echo "UPSTREAM_REPO=$UPSTREAM_REPO" >> $GITHUB_ENV
|
||||
echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV
|
||||
|
||||
- name: Sync from Upstream Repository
|
||||
run: |
|
||||
echo "Syncing from upstream repository $UPSTREAM_REPO on branch $TARGET_BRANCH"
|
||||
|
||||
# Perform fetch and merge, attempting to resolve conflicts by preferring the upstream changes
|
||||
git fetch "$UPSTREAM_REPO" "$TARGET_BRANCH"
|
||||
git merge FETCH_HEAD -m "Merge changes from upstream $UPSTREAM_REPO/$TARGET_BRANCH" || {
|
||||
echo "Conflict detected. Resolving by preferring upstream changes..."
|
||||
git merge --strategy-option theirs --no-edit FETCH_HEAD
|
||||
}
|
||||
|
||||
|
||||
- name: Push changes if there are updates
|
||||
env:
|
||||
BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR
|
||||
run: |
|
||||
if [ "$(git status --porcelain)" ]; then
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
git push origin "$BRANCH_NAME"
|
||||
else
|
||||
echo "No changes to push."
|
||||
fi
|
||||
|
||||
- name: Create Pull Request
|
||||
if: success() && steps.push.outputs.BRANCH_NAME != '' # Only run if there are changes
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "Sync with upstream changes from $UPSTREAM_REPO"
|
||||
branch: ${{ steps.push.outputs.BRANCH_NAME }}
|
||||
title: "Sync with upstream $UPSTREAM_REPO"
|
||||
body: |
|
||||
This PR merges the latest changes from the upstream repository:
|
||||
- **Repository**: $UPSTREAM_REPO
|
||||
- **Branch**: $TARGET_BRANCH
|
||||
|
||||
## Conflict Resolution Instructions
|
||||
If there are conflicts in this PR, you can resolve them locally by following these steps:
|
||||
|
||||
1. **Fetch the remote branch**:
|
||||
```bash
|
||||
git fetch origin ${{ steps.push.outputs.BRANCH_NAME }}
|
||||
```
|
||||
|
||||
2. **Checkout the branch**:
|
||||
```bash
|
||||
git checkout ${{ steps.push.outputs.BRANCH_NAME }}
|
||||
```
|
||||
|
||||
3. **Merge the upstream branch manually**:
|
||||
```bash
|
||||
git fetch https://github.com/flathub/$UPSTREAM_REPO $TARGET_BRANCH
|
||||
git merge FETCH_HEAD
|
||||
```
|
||||
|
||||
4. **Resolve any conflicts**:
|
||||
Open each conflicted file and manually resolve the conflicts. Then mark each file as resolved:
|
||||
```bash
|
||||
git add <file-with-conflicts>
|
||||
```
|
||||
|
||||
5. **Complete the merge**:
|
||||
```bash
|
||||
git commit
|
||||
```
|
||||
|
||||
6. **Push the resolved branch**:
|
||||
```bash
|
||||
git push origin ${{ steps.push.outputs.BRANCH_NAME }}
|
||||
```
|
||||
base: $TARGET_BRANCH
|
||||
labels: ["sync", "upstream"]
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
build-dir/
|
||||
.flatpak-builder/
|
||||
artifacts-repo
|
||||
artifacts-build-dir
|
||||
tree.html
|
11
README.md
Normal file
11
README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# RetroDECK Components Template
|
||||
|
||||
This repository serves as a library for storing common automation workflows and essential files needed when adding new external modules or repositories.
|
||||
|
||||
## How to Use This Repository
|
||||
|
||||
1. **Copy Workflow Templates**
|
||||
Copy the contents of the `workflow-templates` directory into the `.github/workflows` directory of the repository you want to automate. Edit any necessary variables to customize the workflows to your needs (details TBD).
|
||||
|
||||
2. **Copy Common Files**
|
||||
Copy files such as `.gitignore` into the root directory of the target repository to ensure consistency in configuration and file management.
|
|
@ -1,4 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
git fetch https://github.com/flathub/net.rpcs3.RPCS3 master # Fetch the latest changes from the remote master branch
|
||||
$UPSTREAM_REPO='com.something.else'
|
||||
$TARGET_BRANCH='master'
|
||||
|
||||
git fetch https://github.com/flathub/"$UPSTREAM_REPO" "$TARGET_BRANCH" # Fetch the latest changes from the remote master branch
|
||||
git merge FETCH_HEAD # Merge the fetched changes into your current branch
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"only-arches": ["x86_64"]
|
||||
}
|
20
workflow_templates/build-artifacts.yml
Normal file
20
workflow_templates/build-artifacts.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: "Build Artifacts for RetroDECK main manifest"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
Building-project:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: "Install dependencies"
|
||||
uses: RetroDECK/components-template/.github/workflows/install_dependencies.yml@main
|
||||
|
||||
- name: "Build project"
|
||||
uses: RetroDECK/components-template/.github/workflows/build_artifacts.yml@main
|
15
workflow_templates/pr-from-upstream.yml
Normal file
15
workflow_templates/pr-from-upstream.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
name: "Sync with Upstream and Create PR"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
schedule:
|
||||
- cron: "30 0 * * *" # Run every day at 00:30 UTC (9:30 JST)
|
||||
|
||||
jobs:
|
||||
Upstream-sync:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: "Sync with upstream"
|
||||
uses: RetroDECK/components-template/.github/workflows/pr_from_upstream.yml@main
|
Loading…
Reference in a new issue