Skip to content

Commit

Permalink
feat(pre-commit): add option to run as Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
drts01 committed Aug 18, 2021
1 parent 081cb3c commit 806e9b8
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,20 @@ jobs:
- run: make lint
- name: Lint bash scripts
run: shellcheck ./scripts/download-actionlint.bash ./playground/post-install.bash ./playground/deploy.bash
docker:
name: Test Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build image
id: image
uses: docker/build-push-action@v2
with:
build-args: |
GOLANG_VER=1.16
push: false
- name: Test Docker image
run: docker container run
--mount type=bind,source="$(pwd)",target=/mnt/app
--workdir /mnt/app
-- ${{ steps.image.outputs.digest }} --verbose
18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,21 @@ jobs:
git -c user.email='41898282+github-actions[bot]@users.noreply.github.com' -c user.name='github-actions[bot]' commit -m "update version to $ver in download-actionlint.bash"
git log -n 1
git push
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
build-args: |
GOLANG_VER=1.16
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/actionlint:${GITHUB_REF#refs/tags/}
${{ secrets.DOCKER_HUB_USERNAME }}/actionlint:latest
7 changes: 7 additions & 0 deletions .pre-commit-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@
types: ["yaml"]
files: "^.github/workflows/"
entry: actionlint
- id: actionlint-docker
name: Lint GitHub Actions workflow file Docker
description: Runs actionlint Docker image to lint GitHub Actions workflow files
language: docker_image
types: ["yaml"]
files: "^.github/workflows/"
entry: rhysd/actionlint
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG GOLANG_VER=latest
ARG ALPINE_VER=latest

FROM golang:${GOLANG_VER} as builder
WORKDIR /go/src/app
COPY go.* *.go ./
COPY cmd cmd/
RUN go build ./cmd/actionlint

FROM alpine:${ALPINE_VER}
COPY --from=builder /go/src/app/actionlint /usr/local/bin/
RUN apk add shellcheck py3-pyflakes
USER guest
ENTRYPOINT ["/usr/local/bin/actionlint"]
9 changes: 9 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,15 @@ repos:
- id: actionlint
```

or alternatively, run actionlint with Docker:
```yaml
---
repos:
- repo: https://github.com/rhysd/actionlint
rev: main
hooks:
- id: actionlint-docker
```
---

[Checks](checks.md) | [Installation](install.md) | [Configuration](config.md) | [Go API](api.md) | [References](reference.md)
Expand Down

0 comments on commit 806e9b8

Please sign in to comment.