mirror of
https://github.com/Borales/actions-yarn.git
synced 2026-04-03 11:12:17 +08:00
commit
65448b3ccb
83
.github/main.workflow
vendored
83
.github/main.workflow
vendored
@ -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"
|
||||
}
|
||||
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
@ -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
|
||||
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
|
||||
21
.github/workflows/docker-publish.yml
vendored
Normal file
21
.github/workflows/docker-publish.yml
vendored
Normal file
@ -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
|
||||
@ -1,5 +1,10 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 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)
|
||||
|
||||
- Docker now uses the full image `node:10` and `entrypoint.sh` accepts extra NPM settings (thanks to [@Embraser01](https://github.com/Embraser01))
|
||||
|
||||
13
Dockerfile
13
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 <bordun.alexandr@gmail.com>"
|
||||
|
||||
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"]
|
||||
|
||||
53
README.md
53
README.md
@ -6,33 +6,24 @@ 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
|
||||
```
|
||||
|
||||
> `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))
|
||||
@ -46,13 +37,9 @@ action "Publish" {
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
18
action.yml
Normal file
18
action.yml
Normal file
@ -0,0 +1,18 @@
|
||||
name: 'GitHub Action for Yarn'
|
||||
description: 'Wraps the yarn CLI to enable common yarn commands'
|
||||
inputs:
|
||||
cmd:
|
||||
description: 'Yarn command'
|
||||
required: true
|
||||
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 }}
|
||||
@ -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
|
||||
10
script/test
10
script/test
@ -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
|
||||
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
echo "Fake yarn"
|
||||
@ -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' ]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user