-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 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,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" |
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,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 |
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,83 @@ | ||
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | ||
|
||
# TODO: share this action with all packages | ||
# https://docs.github.com/en/actions/using-workflows/reusing-workflows | ||
|
||
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) | ||
rake osc:sr | tee $OUTFILE | ||
SR=$(grep "^created request id [0-9]+" $OUTFILE | sed -e 's/created request id //') | ||
# pass the SR number | ||
echo "submit=$SR" >> $GITHUB_OUTPUT | ||
rm $OUTFILE | ||
- name: Success status comment | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
SUBMIT: ${{ steps.rake.outputs.submit }} | ||
run: | | ||
PR=$(gh pr list --state merged --search ${{ github.sha }} --json number --jq '.[0].number') | ||
if [ -n "$PR" ] | ||
echo "Found pull request $PR (${{ github.server_url }}/${{ github.repository }}/pull/$PR)" | ||
JOB_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
MSG=":heavy_check_mark: Autosubmission job [#${{ github.run_id }}]($JOB_URL) successfully finished" | ||
if [ -n "$SUBMIT"] | ||
SR_URL="https://build.opensuse.org/request/show/$SUBMIT" | ||
echo "Created submit request $SUBMIT ($SR_URL)" | ||
MSG="$MSG\n :heavy_check_mark: Created submit request [#$SUBMIT]($SR_URL)" | ||
fi | ||
gh issue comment $PR --body "$MSG" | ||
else | ||
echo "Pull request not found, skipping status comment" | ||
fi | ||
# TODO: handle failures |