3
0
Fork 0
mirror of https://gitea.com/docker/metadata-action.git synced 2024-11-22 03:59:33 +01:00

Add workflows

This commit is contained in:
CrazyMax 2020-10-25 03:21:46 +01:00
parent 03eb07f964
commit 98414716d9
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
10 changed files with 250 additions and 11 deletions

BIN
.github/ghaction-docker-meta.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

77
.github/labels.yml vendored Normal file
View file

@ -0,0 +1,77 @@
## more info https://github.com/crazy-max/ghaction-github-labeler
- # automerge
name: ":bell: automerge"
color: "8f4fbc"
description: ""
- # bot
name: ":robot: bot"
color: "69cde9"
description: ""
- # bug
name: ":bug: bug"
color: "b60205"
description: ""
- # dependencies
name: ":game_die: dependencies"
color: "0366d6"
description: ""
- # documentation
name: ":memo: documentation"
color: "c5def5"
description: ""
- # duplicate
name: ":busts_in_silhouette: duplicate"
color: "cccccc"
description: ""
- # enhancement
name: ":sparkles: enhancement"
color: "0054ca"
description: ""
- # feature request
name: ":bulb: feature request"
color: "0e8a16"
description: ""
- # feedback
name: ":mega: feedback"
color: "03a9f4"
description: ""
- # future maybe
name: ":rocket: future maybe"
color: "fef2c0"
description: ""
- # good first issue
name: ":hatching_chick: good first issue"
color: "7057ff"
description: ""
- # help wanted
name: ":pray: help wanted"
color: "4caf50"
description: ""
- # hold
name: ":hand: hold"
color: "24292f"
description: ""
- # invalid
name: ":no_entry_sign: invalid"
color: "e6e6e6"
description: ""
- # maybe bug
name: ":interrobang: maybe bug"
color: "ff5722"
description: ""
- # needs more info
name: ":thinking: needs more info"
color: "795548"
description: ""
- # question
name: ":question: question"
color: "3f51b5"
description: ""
- # upstream
name: ":eyes: upstream"
color: "fbca04"
description: ""
- # wontfix
name: ":coffin: wontfix"
color: "ffffff"
description: ""

82
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,82 @@
name: ci
on:
schedule:
- cron: '0 10 * * 0' # everyday sunday at 10am
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
env:
DOCKER_IMAGE: localhost:5000/name/app
jobs:
multi-images:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Docker meta
id: docker_meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
tag-sha: true
docker-push:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Docker meta
id: docker_meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
tag-sha: true
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
-
name: Build and push to local registry
uses: docker/build-push-action@v2
with:
context: ./test
file: ./test/Dockerfile
platforms: linux/amd64,linux/arm64,linux/386
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
-
name: Inspect image
run: |
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
-
name: Check manifest
run: |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

20
.github/workflows/labels.yml vendored Normal file
View file

@ -0,0 +1,20 @@
name: labels
on:
push:
branches:
- 'master'
paths:
- '.github/labels.yml'
- '.github/workflows/labels.yml'
jobs:
labeler:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v3.1.0

53
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,53 @@
name: test
on:
push:
branches:
- 'master'
- 'releases/v*'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
test-containerized:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Validate
run: docker buildx bake validate
-
name: Test
run: docker buildx bake test
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Install
run: yarn install
-
name: Test
run: yarn run test
-
name: Upload coverage
uses: codecov/codecov-action@v1.0.13
if: success()
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/clover.xml

View file

@ -20,6 +20,7 @@ FROM base AS build
RUN yarn build
FROM deps AS test
COPY . .
RUN yarn run test
FROM base AS run-format

View file

@ -12,6 +12,8 @@ GitHub Action to extract metadata (tags, labels) for Docker. This action is part
If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitHub Actions!
![Screenshot](.github/ghaction-docker-meta.png)
___
* [Features](#features)
@ -25,7 +27,7 @@ ___
## Features
* Docker tags generated through GitHub action event and Git metadata
* Docker tags generated from GitHub action event and Git metadata
* [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) used to generate Docker labels
## Usage
@ -104,7 +106,7 @@ Following inputs can be used as `step.with` keys
|---------------------|----------|------------------------------------|
| `images` | List/CSV | List of Docker images to use as base name for tags |
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
| `tag-edge` | String | Branch that will be tagged as edge (default `${{ repo.default_branch }}` |
| `tag-edge` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |

View file

@ -15,15 +15,13 @@ inputs:
default: 'false'
required: false
tag-edge:
description: 'Branch that will be tagged as edge (default ${{ repo.default_branch }})'
description: 'Branch that will be tagged as edge (default repo.default_branch)'
required: false
sep-tags:
description: 'Separator to use for tags output (default \n)'
default: '\n'
required: false
sep-labels:
description: 'Separator to use for labels output (default \n)'
default: '\n'
required: false
github-token:
description: 'GitHub Token as provided by secrets'

9
dist/index.js generated vendored
View file

@ -115,7 +115,6 @@ function run() {
const context = github.context();
const repo = yield github.repo(inputs.githubToken);
core.startGroup(`Context info`);
core.info(`repo: ${context.repo}`);
core.info(`eventName: ${context.eventName}`);
core.info(`sha: ${context.sha}`);
core.info(`ref: ${context.ref}`);
@ -133,12 +132,16 @@ function run() {
core.setOutput('version', version);
const tags = meta.tags();
core.startGroup(`Docker tags`);
core.info(JSON.stringify(tags));
for (let tag of tags) {
core.info(tag);
}
core.endGroup();
core.setOutput('tags', tags.join(inputs.sepTags));
const labels = meta.labels();
core.startGroup(`Docker labels`);
core.info(JSON.stringify(labels));
for (let label of labels) {
core.info(label);
}
core.endGroup();
core.setOutput('labels', labels.join(inputs.sepTags));
}

View file

@ -15,7 +15,6 @@ async function run() {
const context: Context = github.context();
const repo: ReposGetResponseData = await github.repo(inputs.githubToken);
core.startGroup(`Context info`);
core.info(`repo: ${context.repo}`);
core.info(`eventName: ${context.eventName}`);
core.info(`sha: ${context.sha}`);
core.info(`ref: ${context.ref}`);
@ -36,13 +35,17 @@ async function run() {
const tags: Array<string> = meta.tags();
core.startGroup(`Docker tags`);
core.info(JSON.stringify(tags));
for (let tag of tags) {
core.info(tag);
}
core.endGroup();
core.setOutput('tags', tags.join(inputs.sepTags));
const labels: Array<string> = meta.labels();
core.startGroup(`Docker labels`);
core.info(JSON.stringify(labels));
for (let label of labels) {
core.info(label);
}
core.endGroup();
core.setOutput('labels', labels.join(inputs.sepTags));
} catch (error) {