-
Notifications
You must be signed in to change notification settings - Fork 0
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
👷 add job to update open-api-framework #4
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a27887e
:construction_worker: add job to update open-api-framework
Coperh b12591f
:sparkles: create update composite action
Coperh 81df408
:construction: update oaf check to update
Coperh 261b2b3
:bug: fix bash syntax
Coperh 9218181
:bug: remove head reset
Coperh 8384089
:construction: implement PR changes
Coperh 040781a
:construction: add git diff for logging
Coperh e235138
:construction_worker: force create new branch
Coperh f9c55af
:bug: fix git diff always being true
Coperh 053d5f9
:art: make script more clear
Coperh 9dd9d86
:see_no_evil: ignore pycharm directory
Coperh 38e3aa3
:recycle: move script to bin directory
Coperh 60158d2
:bug: fix malformed command
Coperh d9cbbd7
:construction_worker: pin create pr action
Coperh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,3 @@ | ||
|
||
env | ||
.idea |
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,39 @@ | ||
name: "Create or Update PR" | ||
description: "Create or Update a from one branch to another." | ||
author: "Maykin Media" | ||
|
||
inputs: | ||
branch-name: | ||
description: 'Name of the Update Branch' | ||
required: true | ||
commit-message: | ||
description: 'Message of the update commit' | ||
required: true | ||
pr-title: | ||
description: 'Title of the PR' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up Git credentials | ||
shell: bash | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
- name: Set GitHub Path | ||
run: echo "$GITHUB_ACTION_PATH/bin" >> $GITHUB_PATH | ||
shell: bash | ||
env: | ||
GITHUB_ACTION_PATH: ${{ github.action_path }} # location of action.yml | ||
- name: Run Script | ||
shell: bash | ||
run: create-update-pr.sh | ||
env: | ||
BRANCH_NAME: ${{ inputs.branch-name }} | ||
BASE_BRANCH: ${{github.ref_name}} | ||
COMMIT_MESSAGE: ${{ inputs.commit-message }} | ||
PR_TITLE: ${{ inputs.pr-title }} | ||
ACTION_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
RUN_ID: ${{ github.run_id }} | ||
GH_TOKEN: ${{ github.token }} |
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,75 @@ | ||
#!/bin/bash | ||
|
||
if ! [[ $BRANCH_NAME ]]; then | ||
echo "BRANCH_NAME variable is required" | ||
exit 1 | ||
fi | ||
if ! [[ $BASE_BRANCH ]]; then | ||
echo "BASE_BRANCH variable is required" | ||
exit 1 | ||
fi | ||
if ! [[ $COMMIT_MESSAGE ]]; then | ||
echo "COMMIT_MESSAGE variable is required" | ||
exit 1 | ||
fi | ||
if ! [[ $PR_TITLE ]]; then | ||
echo "PR_TITLE variable is required" | ||
exit 1 | ||
fi | ||
if ! [[ $ACTION_URL ]]; then | ||
echo "ACTION_URL variable is required" | ||
exit 1 | ||
fi | ||
if ! [[ $RUN_ID ]]; then | ||
echo "RUN_ID variable is required" | ||
exit 1 | ||
fi | ||
|
||
# Fetch | ||
git fetch | ||
|
||
# Force Create Branch | ||
git switch --force-create "$BRANCH_NAME" | ||
|
||
printf "\nShow Status:" | ||
git status | ||
|
||
|
||
printf "\nCommit Any Changes" | ||
if ! git diff --exit-code --quiet | ||
then | ||
echo "Commiting Files" | ||
git add --all | ||
git commit --message="$COMMIT_MESSAGE" | ||
else | ||
echo "No files to commit" | ||
fi | ||
|
||
printf "\nCheck if Changes have been made" | ||
if ! git ls-remote --exit-code --quiet --heads origin refs/heads/"$BRANCH_NAME" | ||
then | ||
echo "No Remote Found, creating" | ||
git push --set-upstream origin "$BRANCH_NAME" | ||
|
||
elif ! git diff --exit-code --quiet "$BRANCH_NAME"..origin/"$BRANCH_NAME" | ||
then | ||
echo "Changes detected between local and remote. Pushing changes." | ||
git push --force-with-lease --set-upstream origin "$BRANCH_NAME" | ||
else | ||
echo "No Changes detected" | ||
fi | ||
|
||
# Create or Update PR | ||
printf "\nCreate or Update PR" | ||
if gh pr list --head "$BRANCH_NAME" --json title | grep -q '\"title\"' | ||
then | ||
echo "PR found. Adding comment." | ||
gh pr comment "$BRANCH_NAME" --body "Updated by github action [$RUN_ID]($ACTION_URL)" | ||
else | ||
echo "Creating new PR" | ||
gh pr create --base "$BASE_BRANCH" \ | ||
--title "$PR_TITLE" \ | ||
--body "Generated with github action [$RUN_ID]($ACTION_URL)" | ||
fi | ||
|
||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this file being called? Is it defined in the down stream project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called in check
.github/workflows/oaf-check.yml
in this PR which is then called for exam le here: https://github.com/Coperh/objects-api/blob/master/.github/workflows/oaf-check.yml