Skip to content

120: Support protocol v2 #208

120: Support protocol v2

120: Support protocol v2 #208

Workflow file for this run

name: Code formatting
on:
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
format:
name: gofmt validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Install SSH Key
if: github.event.pull_request.head.repo.full_name == github.repository
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: github.com
- name: gofmt
run: gofmt -s -w .
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes (non Fork PRs)
if: github.event.pull_request.head.repo.full_name == github.repository && steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Auto Gofmt'
git config --global user.email '[email protected]'
git remote set-url origin [email protected]:${{ github.repository }}
git commit -am "Automated gofmt changes"
git push
- name: Validate (Fork PRs)
if: github.event.pull_request.head.repo.full_name != github.repository && steps.git-check.outputs.modified == 'true'
run: |
echo "Gofmt code validation failed, please run gofmt on your branch to correctly format your code changes."
exit 1