Skip to content

Commit

Permalink
Added autosubmission GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Dec 4, 2023
1 parent f666947 commit fb1e4c0
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/osc/configure_osc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

# This helper script creates the "osc" configuration file with OBS credentials

CONFIG_FILE="$HOME/.config/osc/oscrc"

# do not overwrite the existing config accidentally
if [ -e "$CONFIG_FILE" ]; then
echo "$CONFIG_FILE already exists"
exit 0
fi

TEMPLATE=$(dirname "${BASH_SOURCE[0]}")/oscrc.template
mkdir -p $(dirname "$CONFIG_FILE")
sed -e "s/@OBS_USER@/$OBS_USER/g" -e "s/@OBS_PASSWORD@/$OBS_PASSWORD/g" "$TEMPLATE" > "$CONFIG_FILE"
8 changes: 8 additions & 0 deletions .github/workflows/osc/oscrc.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[general]
apiurl = https://api.opensuse.org

[https://api.opensuse.org]
user=@OBS_USER@
pass=@OBS_PASSWORD@
credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager
trusted_prj=YaST:Head openSUSE:Factory
69 changes: 69 additions & 0 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions

name: Submit

on:
# when committing to master
push:
# FIXME:
# branches: master
branches: autosubmission

permissions:
issues: write
pull-requests: read

jobs:
submit:
# do not run in forks
if: github.repository_owner == 'yast'

runs-on: ubuntu-latest

container:
image: registry.opensuse.org/yast/head/containers_tumbleweed/yast-rake:latest
# "osc build" needs to mount /proc in the build system chroot
options: --privileged
volumes:
# bind mount the GitHub CLI tool from the Ubuntu host,
# it is a statically linked binary so it should work everywhere
- /usr/bin/gh:/usr/bin/gh

steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Fix permissions to avoid git failures
run: chown -R -c 0 .

- name: Configure osc
run: .github/workflows/osc/configure_osc.sh
env:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}

- name: Run rake
id: rake
# the default timeout is 6 hours, do not wait for that long if osc gets stucked
timeout-minutes: 20
run: |
OUTFILE=$(mktemp -p '' rake_osc_sr_XXXXXXX)
# pass the output file to the next step
echo "out_file=$OUTFILE" >> $GITHUB_OUTPUT
rake osc:sr | tee $OUTFILE
- name: Status comment
if: always()

env:
GH_TOKEN: ${{ github.token }}
OUTFILE: ${{ steps.rake.outputs.out_file }}

run: |
SR=$(grep "^created request id [0-9]+" $OUTFILE | sed -e 's/created request id //')
# use $GITHUB_SHA
PR=$(gh pr list --state merged --search 2fca425e3ebe572fda148fc1c0c0e261729618ff --json number --jq '.[0].number')
echo "Found pull request: $PR"
echo "SR: $SR"
# TODO:
# gh issue comment $PR --body ''

0 comments on commit fb1e4c0

Please sign in to comment.