Skip to content

tests to test

tests to test #11

Workflow file for this run

name: Format, Lint and add changes on push
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
outputs:
PR_URL: ${{ steps.make_pr.outputs.PR_URL }}
steps:
- name: Setup repo
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Run linter
run: deno task lint
- name: Verify formatting
run: deno task fmt
- name: Ensure Changes Exist
run: |
if git diff --exit-code; then
echo "No changes to commit, exiting."
exit 0
fi
- name: Set up Git user
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Create new branch for changes
run: |
BRANCH_NAME="fmt/${{ github.sha }}"
git branch "$BRANCH_NAME"
git switch "$BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Push changes
run: |
git commit -am "deno formatting"
git push https://x-access-token:${{ github.token }}@github.com/${{ github.repository }} "${{ env.BRANCH_NAME }}"
- name: Authenticate GitHub CLI
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Create Pull Request
id: make_pr
run: |
PR_URL=$(gh pr create \
--head "fmt/${{ github.sha }}" \
--base "main" \
--title "Deno formatting changes" \
--body "This PR includes formatting updates made by the workflow." \
--reviewer "${{ github.actor }}" \
2>&1)
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
echo "$PR_URL"
merge-pr:
runs-on: ubuntu-latest
needs: test
env:
PR_URL: ${{ needs.test.outputs.PR_URL }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Approve and merge pull request
run: |
PR_NUMBER=$(echo "$PR_URL" | sed 's/.*\/pull\/\([0-9]*\)/\1/')
gh pr review "$PR_NUMBER" --approve --repo ${{ github.repository }}
gh pr merge "$PR_NUMBER" --merge --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ github.token }}