Skip to content

Commit a1c374b

Browse files
authored
Build the Action as a Container (#6)
* Build the Action as a Container to save people from building it every time * Fix folders * Fix stage name * Remove src from the directory * Update add-matcher to use :: As per actions/toolkit#59 Signed-off-by: Dan Webb <[email protected]>
1 parent 9a81dc6 commit a1c374b

9 files changed

+92
-37
lines changed

.github/workflows/branchcleanup.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Branch Cleanup
3+
# This workflow is triggered on all closed pull requests.
4+
# However the script does not do anything it a merge was not performed.
5+
'on':
6+
pull_request:
7+
types: [closed]
8+
9+
env:
10+
NO_BRANCH_DELETED_EXIT_CODE: 0
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: jessfraz/branch-cleanup-action@master
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Test container builds
3+
4+
'on':
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Code checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Build and push
16+
uses: docker/build-push-action@v2
17+
with:
18+
context: .
19+
platforms: linux/amd64
20+
push: false
21+
tags: |
22+
ghcr.io/${{ github.repository }}:edge

.github/workflows/publish.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Publish container
3+
'on':
4+
release:
5+
types: [published]
6+
jobs:
7+
push_to_registry:
8+
name: Publish to GitHub Container Registry
9+
runs-on: ubuntu-latest
10+
permissions:
11+
packages: write
12+
contents: read
13+
steps:
14+
- name: Get the tag version
15+
id: get_tag
16+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
17+
18+
- name: Code checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v1
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.repository_owner }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Build and push
29+
uses: docker/build-push-action@v2
30+
with:
31+
context: .
32+
platforms: linux/amd64
33+
push: true
34+
tags: |
35+
ghcr.io/${{ github.repository }}:${{ steps.get_tag.outputs.VERSION }}
36+
ghcr.io/${{ github.repository }}:latest

workflows/release.yml .github/workflows/release.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
---
12
name: release
2-
on:
3+
'on':
34
push:
45
branches:
5-
- master
6+
- main
67
jobs:
78
build:
89
runs-on: ubuntu-latest
910
steps:
10-
- uses: actions/checkout@master
11+
- uses: actions/checkout@main
1112
- name: Bump version and push tag
1213
uses: mathieudutour/github-tag-action@v1
1314
with:

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"yaml.schemas": {
3+
"https://json.schemastore.org/github-action.json": "file:///Users/dmw/repos/actionshub/yamllint/workflows/build-container.yaml"
4+
}
5+
}

Dockerfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
FROM python
22

33
RUN pip install yamllint
4+
ENV MATCHERS_DIR="._actionshub_problem-matchers"
5+
ENV MATCHER_FILE="${MATCHERS_DIR}/yamllint.json"
46

5-
COPY . .
7+
RUN mkdir -p ${MATCHERS_DIR}
8+
COPY yamllint.json ${MATCHER_FILE}
9+
RUN echo "::[add-matcher]${MATCHER_FILE}"
610

7-
RUN chmod +x /entrypoint.sh
8-
9-
ENTRYPOINT ["bash", "/entrypoint.sh"]
11+
ENTRYPOINT ["yamllint",".", "--format", "github"]

action.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
---
12
name: 'YAML Lint Action'
23
author: 'Jason Field'
34
description: 'Run yamllint on your yaml files with ease'
45
runs:
56
using: 'docker'
6-
image: 'Dockerfile'
7+
image: docker://ghcr.io/actionshub/yamllint:1.0.1
78
branding:
89
icon: 'edit-3'
910
color: 'red'

entrypoint.sh

-12
This file was deleted.

workflows/branchcleanup.yml

-17
This file was deleted.

0 commit comments

Comments
 (0)