mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
141 lines
3.8 KiB
YAML
141 lines
3.8 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
|
|
env:
|
|
GO_VERSION: "1.24.2"
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Build binary
|
|
run: make build
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Run tests
|
|
run: make test
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
file: ./coverage.out
|
|
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Verify dependencies
|
|
run: make verify
|
|
|
|
- name: Check formatting
|
|
run: make goimports checkfmt
|
|
|
|
- name: Run linters
|
|
run: make golangci lint
|
|
|
|
- name: Run Staticcheck
|
|
run: make staticcheck
|
|
|
|
- name: Check License headers
|
|
run: |
|
|
go install github.com/google/addlicense@latest
|
|
|
|
addlicense -check $(find . -type f -name "*.go")
|
|
addlicense -check $(find . -type f -name "*.sh")
|
|
addlicense -check $(find . -type f -name "Dockerfile")
|
|
|
|
- name: Check docs
|
|
if: "!contains(github.ref, 'refs/heads/master')"
|
|
run: make docs && test -z "$(git status --porcelain)" || exit 1
|
|
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker
|
|
uses: docker/login-action@v3
|
|
if: env.REGISTRY_USERNAME != ''
|
|
with:
|
|
registry: quay.io
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build and push Docker image
|
|
if: env.REGISTRY_USERNAME != '' && contains(github.ref, 'refs/heads/master')
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
outputs: "type=registry,push=true"
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: quay.io/${{ github.event.repository.name }}/terraform-docs:edge
|
|
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Prepare docs
|
|
if: contains(github.ref, 'refs/heads/master')
|
|
run: ./scripts/docs/prepare-site.sh
|
|
|
|
- name: Publish to website
|
|
uses: drud/action-cross-commit@master
|
|
if: contains(github.ref, 'refs/heads/master')
|
|
with:
|
|
source-folder: site/content
|
|
destination-repository: https://${{ secrets.COMMITTER_USERNAME }}:${{ secrets.COMMITTER_TOKEN }}@github.com/terraform-docs/website
|
|
destination-folder: content
|
|
destination-branch: main
|
|
git-user: terraform-docs-bot
|
|
git-user-email: bot@terraform-docs.io
|
|
git-commit-message: |-
|
|
Update website content
|
|
|
|
from: https://github.com/terraform-docs/terraform-docs/commit/${{ github.sha }}
|