-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
55 additions
and
16 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,7 @@ | ||
mutation($input: CreateCommitOnBranchInput!) { | ||
createCommitOnBranch(input: $input) { | ||
commit { | ||
url | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -28,21 +28,53 @@ jobs: | |
- name: Setup git | ||
run: echo ${{ github.head_ref || github.ref_name }} | ||
|
||
- name: List current directory structure | ||
run: ls -R /home/runner/work/house-of-fun/house-of-fun | ||
|
||
- name: Create a change | ||
- name: Create Commit on Branch using GraphQL API | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
mkdir -p code | ||
touch code/test1.txt | ||
git add code/test1.txt | ||
# Define GraphQL mutation | ||
mutation=' | ||
mutation($input: CreateCommitOnBranchInput!) { | ||
createCommitOnBranch(input: $input) { | ||
commit { | ||
url | ||
} | ||
} | ||
} | ||
' | ||
# Define the input payload for the mutation | ||
branch="feature/signed-commits-testing" # Update with your target branch | ||
message="Automated commit via GraphQL" | ||
filePath="README.md" # Update with the file you want to modify | ||
fileContent="This is an automated update." | ||
# Commit all changed files back to the repository | ||
- uses: planetscale/[email protected] | ||
with: | ||
commit_message: "🤖 fmt" | ||
repo: ${{ github.repository }} | ||
branch: ${{ github.head_ref || github.ref_name }} | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
# Create the payload for the mutation | ||
payload=$(jq -n \ | ||
--arg branch "$branch" \ | ||
--arg message "$message" \ | ||
--arg filePath "$filePath" \ | ||
--arg fileContent "$fileContent" \ | ||
'{ | ||
"query": $mutation, | ||
"variables": { | ||
"input": { | ||
"branch": { "repositoryName": "house-of-fun", "ownerName": "ep-93", "branchName": $branch }, | ||
"message": $message, | ||
"fileChanges": { | ||
"additions": [{ | ||
"path": $filePath, | ||
"contents": $fileContent | ||
}] | ||
} | ||
} | ||
} | ||
}' | ||
) | ||
# Make the API call | ||
curl -X POST \ | ||
-H "Authorization: bearer $GITHUB_TOKEN" \ | ||
-H "Content-Type: application/json" \ | ||
-d "$payload" \ | ||
https://api.github.com/graphql |