Skip to content

Add a GitHub Action to lint my Caddyfiles #19

Add a GitHub Action to lint my Caddyfiles

Add a GitHub Action to lint my Caddyfiles #19

Workflow file for this run

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