Factory/.gitea/workflows/pr_project.yaml
Nicolas Belouin 8f20b3433e
All checks were successful
Synchronize Project Config / Update prjconf in OBS (push) Successful in -5s
Synchronize Project Metadata / sync-prj-meta (push) Successful in 3s
Fix PR closed workflow
Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
2025-02-24 15:44:23 +01:00

62 lines
2.3 KiB
YAML

name: Build PR in OBS
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- closed
branches-ignore:
- "devel"
concurrency:
group: ${{ gitea.workflow }}-${{ gitea.ref }}
cancel-in-progress: true
jobs:
sync-pr-project:
name: "Build PR in OBS"
runs-on: tumbleweed
steps:
- name: Setup OSC
run: |
zypper in -y python3-jinja2
mkdir -p ~/.config/osc
cat >~/.config/osc/oscrc <<'EOF'
[general]
apiurl = https://api.opensuse.org
[https://api.opensuse.org]
user=${{ vars.OBS_USERNAME }}
pass=${{ secrets.OBS_PASSWORD }}
EOF
# Waiting on PR to get merged for support in upstream action/checkout action
- uses: 'https://github.com/yangskyboxlabs/action-checkout@sha256'
name: Checkout repository
with:
object-format: 'sha256'
- name: "[if PR is closed] Delete project in OBS"
run: |
if [ "${{ gitea.event.action }}" = "closed" ]; then
PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')"
osc rdelete -f -r -m "PR closed" "${PROJECT}:Staging:PR-${{ gitea.event.number }}"
fi
- name: "Setup PR project in OBS"
env:
SCM_URL: ${{ gitea.event.pull_request.head.repo.clone_url }}#${{ gitea.head_ref }}
run: |
if [ "${{ gitea.event.action }}" != "closed" ]; then
PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')"
python3 .obs/render_meta.py --pr ${{ gitea.event.number }} --scm-url "${SCM_URL}" | osc meta prj "${PROJECT}:Staging:PR-${{ gitea.event.number }}" -F -
echo "Project created ${PROJECT}:Staging:PR-${{ gitea.event.number }}"
echo "Follow build at: https://build.opensuse.org/project/monitor/${PROJECT}:Staging:PR-${{ gitea.event.number }}"
fi
- env:
GIT_SHA: ${{ gitea.event.pull_request.head.sha }}
name: "Wait for OBS to build the project"
run: |
if [ "${{ gitea.event.action }}" != "closed" ]; then
PROJECT="$(grep PROJECT .obs/common.py | sed 's/PROJECT = "\(.*\)"/\1/')"
export OBS_PROJECT="${PROJECT}:Staging:PR-${{ gitea.event.number }}"
python3 .obs/wait_obs.py
fi