From ab1419e4cbe21653d4d16f60c7832756b51b6b74 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 22:43:10 +0200 Subject: [PATCH 01/14] Workflow test --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74d35e4..4eaf0c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,15 +11,15 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 12 - - name: Docker Lint - uses: docker://replicated/dockerfilelint - with: - args: Dockerfile - - name: Shell Lint - uses: actions/bin/shellcheck@master - with: - args: entrypoint.sh - - name: Test - uses: actions/bin/bats@master - with: - args: test/*.bats +# - name: Docker Lint +# uses: docker://replicated/dockerfilelint +# with: +# args: Dockerfile +# - name: Shell Lint +# uses: actions/bin/shellcheck@master +# with: +# args: entrypoint.sh +# - name: Test +# uses: actions/bin/bats@master +# with: +# args: test/*.bats From ae80f819cc20d632f537fdef92e4ea00e5b02c21 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 22:45:19 +0200 Subject: [PATCH 02/14] Docker lint --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eaf0c5..f7b790f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,10 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 12 -# - name: Docker Lint -# uses: docker://replicated/dockerfilelint -# with: -# args: Dockerfile + - name: Docker Lint + uses: docker://replicated/dockerfilelint + with: + args: Dockerfile # - name: Shell Lint # uses: actions/bin/shellcheck@master # with: From 9907c411e85b3fafc54b7cf3750dab2038a8d587 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 22:48:43 +0200 Subject: [PATCH 03/14] Docker lint --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7b790f..dd97faf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: with: node-version: 12 - name: Docker Lint - uses: docker://replicated/dockerfilelint + uses: replicated/dockerfilelint@master with: args: Dockerfile # - name: Shell Lint From 9cdb6a613d285696a536f5461ca6a4c2a3a8838d Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 22:50:36 +0200 Subject: [PATCH 04/14] fixing name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd97faf..d3f7aec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: with: node-version: 12 - name: Docker Lint - uses: replicated/dockerfilelint@master + uses: replicatedhq/dockerfilelint@master with: args: Dockerfile # - name: Shell Lint From bde4840b6faac4e9c62ed01f67fefbfe3963448f Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:23:16 +0200 Subject: [PATCH 05/14] Lint --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3f7aec..e8059fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,9 @@ jobs: with: node-version: 12 - name: Docker Lint - uses: replicatedhq/dockerfilelint@master + uses: docker://replicated/dockerfilelint:latest with: - args: Dockerfile + args: ./Dockerfile # - name: Shell Lint # uses: actions/bin/shellcheck@master # with: From 8148c8b160766a5fe1b8f926a93afd291ead99c8 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:32:24 +0200 Subject: [PATCH 06/14] Removing test files --- Brewfile | 2 -- script/bootstrap | 15 --------------- script/test | 10 ---------- test/bin/yarn | 2 -- 4 files changed, 29 deletions(-) delete mode 100644 Brewfile delete mode 100755 script/bootstrap delete mode 100755 script/test delete mode 100755 test/bin/yarn diff --git a/Brewfile b/Brewfile deleted file mode 100644 index 7772992..0000000 --- a/Brewfile +++ /dev/null @@ -1,2 +0,0 @@ -brew "bats" -brew "shellcheck" diff --git a/script/bootstrap b/script/bootstrap deleted file mode 100755 index 5144b6a..0000000 --- a/script/bootstrap +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# script/bootstrap: Resolve dependencies that the application requires to run. - -# Exit if any subcommand fails -set -e - -# Ensure we're always running from the project root -cd "$(dirname "$0")/.." - -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then - brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle - } -fi diff --git a/script/test b/script/test deleted file mode 100755 index c131299..0000000 --- a/script/test +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Exit if any subcommand fails -set -e - -# Ensure we're always running from the project root -cd "$(dirname "$0")/.." - -bats test/*.bats -shellcheck *.sh diff --git a/test/bin/yarn b/test/bin/yarn deleted file mode 100755 index 1632951..0000000 --- a/test/bin/yarn +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "Fake yarn" From 3dbac8fd64fd882088590cea66ac4ce01941311f Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:32:40 +0200 Subject: [PATCH 07/14] Adding initial action.yml --- action.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..58f439d --- /dev/null +++ b/action.yml @@ -0,0 +1,14 @@ +name: 'GitHub Action for Yarn' +description: 'Wraps the yarn CLI to enable common yarn commands' +inputs: + cmd: + description: 'Yarn command' + required: true +outputs: + time: # id of output + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.cmd }} From 4e66af06744ebec814a45dd1ec659c3a05ee5cf7 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:33:06 +0200 Subject: [PATCH 08/14] Switching to node:10.16-alpine --- Dockerfile | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02d879b..3f5b28a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,4 @@ -FROM node:10 - -LABEL version="1.1.0" -LABEL repository="https://github.com/Borales/actions-yarn" -LABEL homepage="https://github.com/Borales/actions-yarn" -LABEL maintainer="Oleksandr Bordun " - -LABEL com.github.actions.name="GitHub Action for Yarn" -LABEL com.github.actions.description="Wraps the yarn CLI to enable common yarn commands." -LABEL com.github.actions.icon="package" -LABEL com.github.actions.color="blue" -# COPY LICENSE README.md THIRD_PARTY_NOTICE.md / +FROM node:10.16-alpine COPY "entrypoint.sh" "/entrypoint.sh" ENTRYPOINT ["/entrypoint.sh"] From 84bafda24cb6cdf01d31c8df99895c36ab74b328 Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:34:45 +0200 Subject: [PATCH 09/14] Removing ci.yml --- .github/workflows/ci.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e8059fd..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - run: - name: Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/setup-node@v1 - with: - node-version: 12 - - name: Docker Lint - uses: docker://replicated/dockerfilelint:latest - with: - args: ./Dockerfile -# - name: Shell Lint -# uses: actions/bin/shellcheck@master -# with: -# args: entrypoint.sh -# - name: Test -# uses: actions/bin/bats@master -# with: -# args: test/*.bats From a162e275b0bb2a8b0937179f3a8e7ece9720518c Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:46:44 +0200 Subject: [PATCH 10/14] Updating CHANGELOG and README --- CHANGELOG.md | 4 ++++ README.md | 37 +++++++++++++------------------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adcbdf9..307f47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.0.0 (14 Oct 2019) + +- Migrated to the latest Github Action syntax + ## 1.1.0 (22 Apr 2019) - Docker now uses the full image `node:10` and `entrypoint.sh` accepts extra NPM settings (thanks to [@Embraser01](https://github.com/Embraser01)) diff --git a/README.md b/README.md index f608b2a..98a6d7b 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,20 @@ This Action for [yarn](https://yarnpkg.com) enables arbitrary actions with the ` ## Usage -An example workflow to build, test, and publish an npm package to the default public registry follows: +An example workflow how to install packages via Yarn (using repository syntax): -```hcl -workflow "Build, Test, and Publish" { - on = "push" - resolves = ["Publish"] -} - -action "Build" { - uses = "Borales/actions-yarn@master" - args = "install" -} - -action "Test" { - needs = "Build" - uses = "Borales/actions-yarn@master" - args = "test" -} - -action "Publish" { - needs = "Test" - uses = "Borales/actions-yarn@master" - args = "publish --access public" - secrets = ["NPM_AUTH_TOKEN"] -} +```yml +name: CI +on: [push] +jobs: + build: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: borales/actions-yarn@2.0.0 + with: + cmd: install ``` ### Secrets From 0246406bde6fb7e23fee66a32adb09dc2530bccd Mon Sep 17 00:00:00 2001 From: Borales Date: Sun, 13 Oct 2019 23:56:24 +0200 Subject: [PATCH 11/14] Defining npm token and registry --- action.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 58f439d..581286a 100644 --- a/action.yml +++ b/action.yml @@ -4,11 +4,15 @@ inputs: cmd: description: 'Yarn command' required: true -outputs: - time: # id of output - description: 'The time we greeted you' + auth-token: + description: 'NPM_AUTH_TOKEN' + registry-url: + description: 'NPM_REGISTRY_URL' runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.cmd }} + env: + NPM_AUTH_TOKEN: ${{ inputs.auth-token }} + NPM_REGISTRY_URL: ${{ inputs.registry-url }} From f5b369fc014cad5b243821516f72249557ae805d Mon Sep 17 00:00:00 2001 From: Borales Date: Mon, 14 Oct 2019 00:00:15 +0200 Subject: [PATCH 12/14] Cleanup --- test/entrypoint.bats | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 test/entrypoint.bats diff --git a/test/entrypoint.bats b/test/entrypoint.bats deleted file mode 100644 index 38cb2e4..0000000 --- a/test/entrypoint.bats +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bats - -PATH="$PATH:$BATS_TEST_DIRNAME/bin" - -function setup() { - # Ensure GITHUB_WORKSPACE is set - export GITHUB_WORKSPACE="${GITHUB_WORKSPACE-"${BATS_TEST_DIRNAME}/.."}" -} - -@test "entrypoint runs successfully" { - run $GITHUB_WORKSPACE/entrypoint.sh help - echo "$output" - [ "$status" -eq 0 ] -} - -@test "npmrc location can be overridden" { - export NPM_CONFIG_USERCONFIG=$( mktemp ) - export NPM_AUTH_TOKEN=NPM_AUTH_TOKEN - run $GITHUB_WORKSPACE/entrypoint.sh help - [ "$status" -eq 0 ] - [ "$(cat $NPM_CONFIG_USERCONFIG)" = $'//registry.npmjs.org/:_authToken=NPM_AUTH_TOKEN\nregistry=registry.npmjs.org' ] -} - -@test "registry can be overridden" { - export NPM_CONFIG_USERCONFIG=$( mktemp ) - export NPM_REGISTRY_URL=someOtherRegistry.someDomain.net - export NPM_AUTH_TOKEN=NPM_AUTH_TOKEN - run $GITHUB_WORKSPACE/entrypoint.sh help - [ "$status" -eq 0 ] - [ "$(cat $NPM_CONFIG_USERCONFIG)" = $'//someOtherRegistry.someDomain.net/:_authToken=NPM_AUTH_TOKEN\nregistry=someOtherRegistry.someDomain.net' ] -} From 05b6c81cc13b9734855e818b636ac5b20f65451c Mon Sep 17 00:00:00 2001 From: Borales Date: Mon, 14 Oct 2019 00:05:38 +0200 Subject: [PATCH 13/14] Updating readme --- CHANGELOG.md | 1 + README.md | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 307f47e..268453e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.0.0 (14 Oct 2019) - Migrated to the latest Github Action syntax +- Using `node:10.16-alpine` as base image ## 1.1.0 (22 Apr 2019) diff --git a/README.md b/README.md index 98a6d7b..0b2ddc3 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,9 @@ jobs: To authenticate with, and publish to, a registry other than `registry.npmjs.org`: -```hcl -action "Publish" { - uses = "Borales/actions-yarn@master" - args = "publish --access public" - env = { - NPM_REGISTRY_URL = "someOtherRegistry.someDomain.net" - } - secrets = ["NPM_AUTH_TOKEN"] -} +```yml +- uses: borales/actions-yarn@2.0.0 + with: + auth-token: ${{ secrets.NPM_TOKEN }} + registry-url: someOtherRegistry.someDomain.net ``` From 60b50482c510bbe0893019128343cd56c230dcc3 Mon Sep 17 00:00:00 2001 From: Borales Date: Mon, 14 Oct 2019 00:12:01 +0200 Subject: [PATCH 14/14] Adding publish to docker --- .github/main.workflow | 83 ---------------------------- .github/workflows/docker-publish.yml | 21 +++++++ README.md | 2 + 3 files changed, 23 insertions(+), 83 deletions(-) delete mode 100644 .github/main.workflow create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index 498d701..0000000 --- a/.github/main.workflow +++ /dev/null @@ -1,83 +0,0 @@ -workflow "Pull Request" { - on = "pull_request" - resolves = ["Docker Lint [PR]", "Shell Lint [PR]", "Test [PR]"] -} - -action "Docker Lint [PR]" { - uses = "docker://replicated/dockerfilelint" - args = "Dockerfile" -} - -action "Shell Lint [PR]" { - uses = "actions/bin/shellcheck@master" - args = "entrypoint.sh" -} - -action "Test [PR]" { - uses = "actions/bin/bats@master" - args = "test/*.bats" -} - -workflow "Build and Publish" { - resolves = [ - "Docker Lint", - "Test", - "Docker Login", - "Docker Publish", - ] - on = "push" -} - -action "Master Branch" { - uses = "actions/bin/filter@master" - args = "branch master" -} - -action "Docker Lint" { - uses = "docker://replicated/dockerfilelint" - needs = ["Master Branch"] - args = "Dockerfile" -} - -action "Shell Lint" { - uses = "actions/bin/shellcheck@master" - needs = ["Master Branch"] - args = "entrypoint.sh" -} - -action "Test" { - uses = "actions/bin/bats@master" - needs = ["Master Branch"] - args = "test/*.bats" -} - -action "Build" { - uses = "actions/docker/cli@master" - needs = [ - "Docker Lint", - "Test", - "Shell Lint", - ] - args = "build -t yarn ." -} - -action "Docker Tag" { - uses = "actions/docker/tag@master" - args = "yarn borales/yarn --no-latest" - needs = ["Build"] -} - -action "Docker Login" { - uses = "actions/docker/login@master" - secrets = ["DOCKER_PASSWORD", "DOCKER_USERNAME"] - needs = ["Build"] -} - -action "Docker Publish" { - uses = "actions/docker/cli@master" - needs = [ - "Docker Login", - "Docker Tag", - ] - args = "push borales/yarn" -} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..183f8ef --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,21 @@ +name: Publish Docker image + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: borales/yarn + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + cache: true diff --git a/README.md b/README.md index 0b2ddc3..d878cdf 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ jobs: cmd: install ``` +> `cmd` value will be used as a command for Yarn + ### Secrets * `NPM_AUTH_TOKEN` - **Optional**. The token to use for authentication with the npm registry. Required for `yarn publish` ([more info](https://docs.npmjs.com/getting-started/working_with_tokens))