From 98414716d94acbfb03376c5604fbb6807f35c05f Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 25 Oct 2020 03:21:46 +0100 Subject: [PATCH] Add workflows --- .github/ghaction-docker-meta.png | Bin 0 -> 6616 bytes .github/labels.yml | 77 +++++++++++++++++++++++++++++ .github/workflows/ci.yml | 82 +++++++++++++++++++++++++++++++ .github/workflows/labels.yml | 20 ++++++++ .github/workflows/test.yml | 53 ++++++++++++++++++++ Dockerfile | 1 + README.md | 6 ++- action.yml | 4 +- dist/index.js | 9 ++-- src/main.ts | 9 ++-- 10 files changed, 250 insertions(+), 11 deletions(-) create mode 100644 .github/ghaction-docker-meta.png create mode 100644 .github/labels.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/labels.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/ghaction-docker-meta.png b/.github/ghaction-docker-meta.png new file mode 100644 index 0000000000000000000000000000000000000000..8c33855386741d64d2368610e599686c1860d0ab GIT binary patch literal 6616 zcmZ8lXIK+kw?+{}s)SAi1ObUaXc9VzQVm6l5TuiY8j3WLCL*ArN(~*QN-+>ZM=25_ zy?3Nn0i`ItT|D2p-#zE9AA9!fz1O?e`>vVwJTvG=I_fl(?35%VBs7{DD*7ZOmmwr1 zmvSgbFIFf7OC2w6K##NxRe3>R5s1Rv;wmr5#|;E7Uc?uBf@2K9yoMNFPrMs;bq?#J z3j*_kU~?Uq;>A^BJWMyfhq$;}yx23hh>z)5om=c7c3_TF&!6M7mN6qi!j!&{@PJ&uaj#|+2%IYBS-J|1H^SrqjLzt$Hp$NQ?i1qn4vsmou)AF^mxC7G^ zsxXJee<&_9NG^*?Dn~lF7{JV?W(uc{Pl~ZU71f{Su$aC5m8s*orsKJ;-od8h*6h&2 zn0QPO#J<=QrVD}iv`=0Ck6up1FGM%`}SYFnHG$>VMxaZa7ZDn zywZ3`9OtlAtLndUQ2`Q?6JysaKB?^~B)Y1StS^};Z;6fvp{}b!G%o#pZSF&PBi}zs zkZYC%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NPR1)zjo`Ud0kPWga5@W=MS@-+mKJDfOD+NNhUq$k9KNaDDen} zxC<@VpWUoz6pL&FM^(k2RtKJ6gPH{xnauyYbVX}5zm4BL+6!)PEaWg;6r5G?oEO^W z{7USY^=P>AO!c~DF*D;<9o6sEq^(%FTjiY6aLfi&betz#oUPt^+@o%8QmwHGP@36s zD$(5xIOjnMe^G{2<^}~sY$mzJ^RcHlaM*3c1^721gn4YNq=fu*_Mus;R!KezL#I?L zx8Z0~9;3YEfS4VE5%~?5oAd&MMSNtR$l*k2wa;b>8N1NDge>z{zT<2I#+SXje?(x< z4vI=LVO8-@0!zssAEYyURZD0eqp7b{>iWK8!r6Zo=Zi=!0YAM*C}PBK>Sc~~z+RA| zZ#I-)XrOb~qVC`Ey;&~_cOW(b?Rx)mwid!IrAPA7zLEYBv4r+OiY}7_4m)4I%4FPH z+gSC8=;^vl!@O-Gn~sC-ZC{F~@5|OAy1@QUUTONUoG@JaLFnn@f18*85tBegXykdK zsNBIo*7sbP%_?V$@;tj`#EXlsp!2IIz-aQWZG#L}=!xkAGvAZduKH2aw(o{xD~)`F z61W5#^wX3Bd3;-n=0`mh%=D+zt-xV8z6o$#k{ZbuO(TU)PZ?rYU2W(z&QfR`gX1-d zXQ3-LXn2b@j~#!d8ohZ#tzwJ*Xb$ zBn|n->u#&>#Q3~&4R^=}jTE`)mEHvrnu}ezBLW?8{3(@BjJC=A8q5FdzePF^xh~;T W!~LvWNSFWoLe^B(QNiA~3jQC1oZ({t literal 0 HcmV?d00001 diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..3444025 --- /dev/null +++ b/.github/labels.yml @@ -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: "" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..98696a7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 0000000..08d5675 --- /dev/null +++ b/.github/workflows/labels.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1fd782c --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 49a7366..6998ab8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 2a9afcf..70c59d1 100644 --- a/README.md +++ b/README.md @@ -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`) | diff --git a/action.yml b/action.yml index 6712b4e..f802c94 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/dist/index.js b/dist/index.js index e9945f1..44ff56a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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)); } diff --git a/src/main.ts b/src/main.ts index ff73bcf..052f891 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 = 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 = 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) {