Upgrade GoLang version and Prometheus client module #253
Workflow file for this run
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
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 |