Skip to content

Add workflow permissions and clean up things (#25) #58

Add workflow permissions and clean up things (#25)

Add workflow permissions and clean up things (#25) #58

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'Validate Readme'
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
permissions:
contents: 'read'
statuses: 'write'
defaults:
run:
shell: 'bash'
jobs:
gen-readme:
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout'
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
- name: 'Setup go'
uses: 'actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5' # ratchet:actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: 'Generate Readme'
run: |-
go run ./scripts/generate/... readme
- name: 'Validate Diff'
run: |
STATUS=$(git status --porcelain)
if [[ -n "$STATUS" ]]; then
echo "ERROR: README has not been updated"
echo ""
echo " Run the following command to update the README: go run scripts/generate.go readme"
exit 1
fi