Skip to content

Add a GitHub Action to lint my Caddyfiles #6

Add a GitHub Action to lint my Caddyfiles

Add a GitHub Action to lint my Caddyfiles #6

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 curl, check version
run: |
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl --version
- name: Install Caddy
run:
# Run apt install -y debian-keyring debian-archive-keyring apt-transport-https curl curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list apt update apt install caddy
# E: Command line option '1' [from -1sLf] is not understood in combination with the other options.
# tee: caddy: Is a directory
# usage: gpg [options] --dearmor [file]
# Error: Process completed with exit code 1.
# These instructions for installing Caddy are taken from
# the Caddy docs:
# https://caddyserver.com/docs/install#static-binaries
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
- name: Format my Caddyfiles
run: find . -name Caddyfile -o -name '*.Caddyfile' | xargs caddy fmt --overwrite
- name: Check for changes
run: git diff --exit-code