Add a GitHub Action to lint my Caddyfiles #19
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: "Lint my Caddyfiles" | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/caddy_fmt.yml' | |
- 'Caddyfile' | |
- '**/Caddyfile' | |
- '**/*.Caddyfile' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/caddy_fmt.yml' | |
- 'Caddyfile' | |
- '**/Caddyfile' | |
- '**/*.Caddyfile' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Check out the repo" | |
uses: actions/checkout@v4 | |
- name: Install Caddy | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh release download \ | |
--repo caddyserver/caddy \ | |
--pattern 'caddy_*_linux_amd64.tar.gz' \ | |
--output caddy.tar.gz | |
tar -xzf caddy.tar.gz --directory /usr/local/bin | |
chmod +x /usr/local/bin/caddy | |
which caddy | |
- name: Format my Caddyfiles | |
run: | | |
find . -name Caddyfile -o -name '*.Caddyfile' | |
find . -name Caddyfile -o -name '*.Caddyfile' | xargs caddy fmt --overwrite | |
- name: Print changes | |
run: git diff | |
- name: Check for changes | |
run: git diff --exit-code |