Skip to content

Commit 9841471

Browse files
committed
Add workflows
1 parent 03eb07f commit 9841471

10 files changed

Lines changed: 250 additions & 11 deletions

File tree

.github/ghaction-docker-meta.png

6.46 KB
Loading

.github/labels.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## more info https://github.com/crazy-max/ghaction-github-labeler
2+
- # automerge
3+
name: ":bell: automerge"
4+
color: "8f4fbc"
5+
description: ""
6+
- # bot
7+
name: ":robot: bot"
8+
color: "69cde9"
9+
description: ""
10+
- # bug
11+
name: ":bug: bug"
12+
color: "b60205"
13+
description: ""
14+
- # dependencies
15+
name: ":game_die: dependencies"
16+
color: "0366d6"
17+
description: ""
18+
- # documentation
19+
name: ":memo: documentation"
20+
color: "c5def5"
21+
description: ""
22+
- # duplicate
23+
name: ":busts_in_silhouette: duplicate"
24+
color: "cccccc"
25+
description: ""
26+
- # enhancement
27+
name: ":sparkles: enhancement"
28+
color: "0054ca"
29+
description: ""
30+
- # feature request
31+
name: ":bulb: feature request"
32+
color: "0e8a16"
33+
description: ""
34+
- # feedback
35+
name: ":mega: feedback"
36+
color: "03a9f4"
37+
description: ""
38+
- # future maybe
39+
name: ":rocket: future maybe"
40+
color: "fef2c0"
41+
description: ""
42+
- # good first issue
43+
name: ":hatching_chick: good first issue"
44+
color: "7057ff"
45+
description: ""
46+
- # help wanted
47+
name: ":pray: help wanted"
48+
color: "4caf50"
49+
description: ""
50+
- # hold
51+
name: ":hand: hold"
52+
color: "24292f"
53+
description: ""
54+
- # invalid
55+
name: ":no_entry_sign: invalid"
56+
color: "e6e6e6"
57+
description: ""
58+
- # maybe bug
59+
name: ":interrobang: maybe bug"
60+
color: "ff5722"
61+
description: ""
62+
- # needs more info
63+
name: ":thinking: needs more info"
64+
color: "795548"
65+
description: ""
66+
- # question
67+
name: ":question: question"
68+
color: "3f51b5"
69+
description: ""
70+
- # upstream
71+
name: ":eyes: upstream"
72+
color: "fbca04"
73+
description: ""
74+
- # wontfix
75+
name: ":coffin: wontfix"
76+
color: "ffffff"
77+
description: ""

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: ci
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * 0' # everyday sunday at 10am
6+
push:
7+
branches:
8+
- '**'
9+
tags:
10+
- 'v*.*.*'
11+
pull_request:
12+
13+
env:
14+
DOCKER_IMAGE: localhost:5000/name/app
15+
16+
jobs:
17+
multi-images:
18+
runs-on: ubuntu-latest
19+
steps:
20+
-
21+
name: Checkout
22+
uses: actions/checkout@v2.3.3
23+
-
24+
name: Docker meta
25+
id: docker_meta
26+
uses: ./
27+
with:
28+
images: |
29+
${{ env.DOCKER_IMAGE }}
30+
ghcr.io/name/app
31+
tag-sha: true
32+
33+
docker-push:
34+
runs-on: ubuntu-latest
35+
services:
36+
registry:
37+
image: registry:2
38+
ports:
39+
- 5000:5000
40+
steps:
41+
-
42+
name: Checkout
43+
uses: actions/checkout@v2.3.3
44+
-
45+
name: Docker meta
46+
id: docker_meta
47+
uses: ./
48+
with:
49+
images: |
50+
${{ env.DOCKER_IMAGE }}
51+
tag-sha: true
52+
-
53+
name: Set up QEMU
54+
uses: docker/setup-qemu-action@v1
55+
-
56+
name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v1
58+
with:
59+
driver-opts: network=host
60+
-
61+
name: Build and push to local registry
62+
uses: docker/build-push-action@v2
63+
with:
64+
context: ./test
65+
file: ./test/Dockerfile
66+
platforms: linux/amd64,linux/arm64,linux/386
67+
push: true
68+
tags: ${{ steps.docker_meta.outputs.tags }}
69+
labels: ${{ steps.docker_meta.outputs.labels }}
70+
-
71+
name: Inspect image
72+
run: |
73+
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
74+
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
75+
-
76+
name: Check manifest
77+
run: |
78+
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
79+
-
80+
name: Dump context
81+
if: always()
82+
uses: crazy-max/ghaction-dump-context@v1

.github/workflows/labels.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: labels
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- '.github/labels.yml'
9+
- '.github/workflows/labels.yml'
10+
11+
jobs:
12+
labeler:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v2.3.3
18+
-
19+
name: Run Labeler
20+
uses: crazy-max/ghaction-github-labeler@v3.1.0

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'releases/v*'
8+
paths-ignore:
9+
- '**.md'
10+
pull_request:
11+
paths-ignore:
12+
- '**.md'
13+
14+
jobs:
15+
test-containerized:
16+
runs-on: ubuntu-latest
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2.3.3
21+
-
22+
name: Validate
23+
run: docker buildx bake validate
24+
-
25+
name: Test
26+
run: docker buildx bake test
27+
28+
test:
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os:
34+
- ubuntu-latest
35+
- macOS-latest
36+
- windows-latest
37+
steps:
38+
-
39+
name: Checkout
40+
uses: actions/checkout@v2.3.3
41+
-
42+
name: Install
43+
run: yarn install
44+
-
45+
name: Test
46+
run: yarn run test
47+
-
48+
name: Upload coverage
49+
uses: codecov/codecov-action@v1.0.13
50+
if: success()
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
file: ./coverage/clover.xml

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FROM base AS build
2020
RUN yarn build
2121

2222
FROM deps AS test
23+
COPY . .
2324
RUN yarn run test
2425

2526
FROM base AS run-format

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ GitHub Action to extract metadata (tags, labels) for Docker. This action is part
1212

1313
If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitHub Actions!
1414

15+
![Screenshot](.github/ghaction-docker-meta.png)
16+
1517
___
1618

1719
* [Features](#features)
@@ -25,7 +27,7 @@ ___
2527

2628
## Features
2729

28-
* Docker tags generated through GitHub action event and Git metadata
30+
* Docker tags generated from GitHub action event and Git metadata
2931
* [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) used to generate Docker labels
3032

3133
## Usage
@@ -104,7 +106,7 @@ Following inputs can be used as `step.with` keys
104106
|---------------------|----------|------------------------------------|
105107
| `images` | List/CSV | List of Docker images to use as base name for tags |
106108
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
107-
| `tag-edge` | String | Branch that will be tagged as edge (default `${{ repo.default_branch }}` |
109+
| `tag-edge` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
108110
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
109111
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
110112

action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ inputs:
1515
default: 'false'
1616
required: false
1717
tag-edge:
18-
description: 'Branch that will be tagged as edge (default ${{ repo.default_branch }})'
18+
description: 'Branch that will be tagged as edge (default repo.default_branch)'
1919
required: false
2020
sep-tags:
2121
description: 'Separator to use for tags output (default \n)'
22-
default: '\n'
2322
required: false
2423
sep-labels:
2524
description: 'Separator to use for labels output (default \n)'
26-
default: '\n'
2725
required: false
2826
github-token:
2927
description: 'GitHub Token as provided by secrets'

dist/index.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ async function run() {
1515
const context: Context = github.context();
1616
const repo: ReposGetResponseData = await github.repo(inputs.githubToken);
1717
core.startGroup(`Context info`);
18-
core.info(`repo: ${context.repo}`);
1918
core.info(`eventName: ${context.eventName}`);
2019
core.info(`sha: ${context.sha}`);
2120
core.info(`ref: ${context.ref}`);
@@ -36,13 +35,17 @@ async function run() {
3635

3736
const tags: Array<string> = meta.tags();
3837
core.startGroup(`Docker tags`);
39-
core.info(JSON.stringify(tags));
38+
for (let tag of tags) {
39+
core.info(tag);
40+
}
4041
core.endGroup();
4142
core.setOutput('tags', tags.join(inputs.sepTags));
4243

4344
const labels: Array<string> = meta.labels();
4445
core.startGroup(`Docker labels`);
45-
core.info(JSON.stringify(labels));
46+
for (let label of labels) {
47+
core.info(label);
48+
}
4649
core.endGroup();
4750
core.setOutput('labels', labels.join(inputs.sepTags));
4851
} catch (error) {

0 commit comments

Comments
 (0)