Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): Back to one PR per change... #47

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions .github/workflows/plugin_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ name: Plugins Update file test

on:
workflow_dispatch:

schedule:
- cron: '0 0 * * *' # run daily at midnight


jobs:
check-plugins:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Configure git & gh
run: |

Expand All @@ -36,7 +36,7 @@ jobs:

- name: print GITHUB_ENV file
run: cat $GITHUB_ENV

- name: Waiting for service to be ready
run: |
# Check If Jenkins is running or not
Expand All @@ -56,30 +56,18 @@ jobs:
echo "No plugins need to be updated"
else
# Changes detected
echo "Plugins have been updated, creating a pull request or modifying an existing one if it exists"
echo "Plugins have been updated, creating a pull request"

PR_TITLE="chore(jenkins): Updates Jenkins plugins"
EXISTING_PR_BRANCH=$(gh pr list --search "$PR_TITLE" --json number,headRefName -q '.data.repository.pullRequests.nodes[0].headRefName')
# Create and checkout new branch
git checkout -b "$BRANCH_NAME"

if [ -z "$EXISTING_PR_BRANCH" ]; then
# No existing PR, create a new one

# Create and checkout new branch
git checkout -b "$BRANCH_NAME"
else
# Existing PR, checkout the existing branch
git checkout "$EXISTING_PR_BRANCH"
fi

# Add and commit changes
git add dockerfiles/plugins.txt
git commit --amend --no-edit
git commit -m "chore(jenkins): Update Jenkins plugins"

# Push changes to GitHub
git push -u origin HEAD
git push -u origin "$BRANCH_NAME"

if [ -z "$EXISTING_PR_BRANCH" ]; then
# No existing PR, create a new one
gh pr create --title "$PR_TITLE" --body "This pull request updates the Jenkins plugins listed in \`plugins.txt\`." --base "$BASE_BRANCH" --head "$BRANCH_NAME"
fi
# Create pull request using gh command
gh pr create --title "chore(jenkins): Updates Jenkins plugins" --body "This pull request updates the Jenkins plugins listed in \`plugins.txt\`." --base "$BASE_BRANCH" --head "$BRANCH_NAME"
fi
Loading