diff --git a/.github/workflows/graphql b/.github/workflows/graphql new file mode 100644 index 0000000..fc0ae7f --- /dev/null +++ b/.github/workflows/graphql @@ -0,0 +1,7 @@ +mutation($input: CreateCommitOnBranchInput!) { + createCommitOnBranch(input: $input) { + commit { + url + } + } +} \ No newline at end of file diff --git a/.github/workflows/test-commit-signing.yml b/.github/workflows/test-commit-signing.yml index 11983f5..9af7332 100644 --- a/.github/workflows/test-commit-signing.yml +++ b/.github/workflows/test-commit-signing.yml @@ -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/ghcommit-action@v0.1.6 - 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