mirror of
https://github.com/Borales/actions-yarn.git
synced 2026-06-24 17:19:26 +08:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fdf0082f89 | |||
| 1937fedd35 | |||
| 9bec063cfa | |||
| d8ce577a6f | |||
| 924bcea8f0 | |||
| 44293a387e | |||
| 1f7c6fbe9c | |||
| f6e2aecf62 | |||
| 5b0b86cdda | |||
| 6207ca676f | |||
| 3eab1c9435 | |||
| f24ed466bd | |||
| c33f8306f2 | |||
| 4ac8b9d200 | |||
| 4965e1a0f0 | |||
| 2c3d31468d | |||
| 045276f30a | |||
| b7482b5362 | |||
| 729ea4ad03 | |||
| 3a3b5a57de | |||
| fb4aea7299 | |||
| 3dce3af319 | |||
| 57dd002262 | |||
| 1e151b00df | |||
| 58112cebd4 | |||
| 496d83e0ee | |||
| 4d9b2c0dc6 | |||
| b7233e8545 | |||
| a39c5ddbda | |||
| 6d5252c0b8 | |||
| e0c8d84b6e | |||
| 4e4261c59f | |||
| 7214980ec5 | |||
| 65448b3ccb | |||
| 60b50482c5 | |||
| 05b6c81cc1 | |||
| f5b369fc01 | |||
| 0246406bde | |||
| a162e275b0 | |||
| 84bafda24c | |||
| 4e66af0674 | |||
| 3dbac8fd64 | |||
| 8148c8b160 | |||
| bde4840b6f | |||
| 9cdb6a613d | |||
| 9907c411e8 | |||
| ae80f819cc | |||
| ab1419e4cb | |||
| 8b95fae89c | |||
| 7f2a916727 | |||
| 5a59b2b2ae | |||
| 658f66ff0b | |||
| 433d223b19 | |||
| 7ba8158c63 | |||
| 02dfec60b1 | |||
| 05eb7c3a78 | |||
| 2f417a09c0 | |||
| 6f4d654ec1 | |||
| 097057d996 | |||
| ae944a02b7 | |||
| ed3b33b7fe | |||
| a918ccf9e6 | |||
| e207ae44f5 |
@@ -1,49 +0,0 @@
|
|||||||
workflow "Build and Publish" {
|
|
||||||
on = "push"
|
|
||||||
resolves = "Docker Publish"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Shell Lint" {
|
|
||||||
uses = "actions/bin/shellcheck@master"
|
|
||||||
args = "entrypoint.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Test" {
|
|
||||||
uses = "actions/bin/bats@master"
|
|
||||||
args = "test/*.bats"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Docker Lint" {
|
|
||||||
uses = "docker://replicated/dockerfilelint"
|
|
||||||
args = ["Dockerfile"]
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Build" {
|
|
||||||
needs = ["Shell Lint", "Test", "Docker Lint"]
|
|
||||||
uses = "actions/docker/cli@master"
|
|
||||||
args = "build -t yarn ."
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Docker Tag" {
|
|
||||||
needs = ["Build"]
|
|
||||||
uses = "actions/docker/tag@master"
|
|
||||||
args = "yarn borales/yarn --no-latest"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Publish Filter" {
|
|
||||||
needs = ["Build"]
|
|
||||||
uses = "actions/bin/filter@master"
|
|
||||||
args = "branch master"
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Docker Login" {
|
|
||||||
needs = ["Publish Filter"]
|
|
||||||
uses = "actions/docker/login@master"
|
|
||||||
secrets = ["DOCKER_USERNAME", "DOCKER_PASSWORD"]
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Docker Publish" {
|
|
||||||
needs = ["Docker Tag", "Docker Login"]
|
|
||||||
uses = "actions/docker/cli@master"
|
|
||||||
args = "push borales/yarn"
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
+22
-1
@@ -1,5 +1,26 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
### 27 Dec 2018
|
## 3.0.0 (8 Jun 2022)
|
||||||
|
|
||||||
|
- Migrating to Python3 (thanks to [@richard-chim](https://github.com/richard-chim))
|
||||||
|
|
||||||
|
## 2.1.0 (8 Nov 2019)
|
||||||
|
|
||||||
|
- Switching to `node:lts` docker image
|
||||||
|
|
||||||
|
## 2.0.2 (6 Nov 2019)
|
||||||
|
|
||||||
|
- Added Git to the Docker image
|
||||||
|
|
||||||
|
## 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))
|
||||||
|
|
||||||
|
## 1.0.0 (27 Dec 2018)
|
||||||
|
|
||||||
- Added Docker credentials
|
- Added Docker credentials
|
||||||
|
|||||||
+3
-12
@@ -1,16 +1,7 @@
|
|||||||
FROM node:10-slim
|
FROM node:lts-alpine
|
||||||
|
|
||||||
LABEL version="1.0.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="#2188b6"
|
|
||||||
# COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
|
|
||||||
|
|
||||||
|
RUN apk add --no-cache git python3 build-base
|
||||||
|
RUN npm i -g --force yarn
|
||||||
COPY "entrypoint.sh" "/entrypoint.sh"
|
COPY "entrypoint.sh" "/entrypoint.sh"
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["help"]
|
CMD ["help"]
|
||||||
|
|||||||
@@ -1,38 +1,38 @@
|
|||||||
# GitHub Actions for Yarn
|
# GitHub Actions for Yarn
|
||||||
|
|
||||||
> Look https://github.com/actions/npm for more details.
|
> Look [github.com/actions/setup-node](https://github.com/actions/setup-node) for more details.
|
||||||
|
|
||||||
This Action for [yarn](https://yarnpkg.com) enables arbitrary actions with the `yarn` command-line client, including testing packages and publishing to a registry.
|
This Action for [yarn](https://yarnpkg.com) enables arbitrary actions with the `yarn` command-line client, including testing packages and publishing to a registry.
|
||||||
|
|
||||||
|
> **Please keep in mind** that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things).
|
||||||
|
Consider using [actions/setup-node](https://github.com/actions/setup-node) to work with Yarn. This repository will be mostly supporting the existing flows.
|
||||||
|
|
||||||
## Usage
|
## 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
|
```yml
|
||||||
workflow "Build, Test, and Publish" {
|
name: CI
|
||||||
on = "push"
|
on: [push]
|
||||||
resolves = ["Publish"]
|
jobs:
|
||||||
}
|
build:
|
||||||
|
name: Test
|
||||||
action "Build" {
|
runs-on: ubuntu-latest
|
||||||
uses = "borales/actions-yarn@master"
|
steps:
|
||||||
args = "install"
|
- uses: actions/checkout@v2
|
||||||
}
|
- uses: borales/actions-yarn@v3.0.0
|
||||||
|
with:
|
||||||
action "Test" {
|
cmd: install # will run `yarn install` command
|
||||||
needs = "Build"
|
- uses: borales/actions-yarn@v3.0.0
|
||||||
uses = "borales/actions-yarn@master"
|
with:
|
||||||
args = "test"
|
cmd: build # will run `yarn build` command
|
||||||
}
|
- uses: borales/actions-yarn@v3.0.0
|
||||||
|
with:
|
||||||
action "Publish" {
|
cmd: test # will run `yarn test` command
|
||||||
needs = "Test"
|
|
||||||
uses = "borales/actions-yarn@master"
|
|
||||||
args = "publish --access public"
|
|
||||||
secrets = ["NPM_AUTH_TOKEN"]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> `cmd` value will be used as a command for Yarn
|
||||||
|
|
||||||
### Secrets
|
### 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))
|
* `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 +46,9 @@ action "Publish" {
|
|||||||
|
|
||||||
To authenticate with, and publish to, a registry other than `registry.npmjs.org`:
|
To authenticate with, and publish to, a registry other than `registry.npmjs.org`:
|
||||||
|
|
||||||
```hcl
|
```yml
|
||||||
action "Publish" {
|
- uses: borales/actions-yarn@v3.0.0
|
||||||
uses = "borales/actions-yarn@master"
|
with:
|
||||||
args = "publish --access public"
|
auth-token: ${{ secrets.NPM_TOKEN }}
|
||||||
env = {
|
registry-url: someOtherRegistry.someDomain.net
|
||||||
NPM_REGISTRY_URL = "someOtherRegistry.someDomain.net"
|
|
||||||
}
|
|
||||||
secrets = ["NPM_AUTH_TOKEN"]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
name: 'GitHub Action for Yarn'
|
||||||
|
description: 'Wraps the yarn CLI to enable common yarn commands'
|
||||||
|
branding:
|
||||||
|
icon: 'package'
|
||||||
|
color: 'blue'
|
||||||
|
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 }}
|
||||||
+10
-3
@@ -4,11 +4,18 @@ set -e
|
|||||||
|
|
||||||
if [ -n "$NPM_AUTH_TOKEN" ]; then
|
if [ -n "$NPM_AUTH_TOKEN" ]; then
|
||||||
# Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc
|
# Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc
|
||||||
NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG-"$HOME/.npmrc"}"
|
NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG:-"$HOME/.npmrc"}"
|
||||||
NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}"
|
NPM_REGISTRY_URL="${NPM_REGISTRY_URL:-registry.npmjs.org}"
|
||||||
|
NPM_STRICT_SSL="${NPM_STRICT_SSL:-true}"
|
||||||
|
NPM_REGISTRY_SCHEME="https"
|
||||||
|
if ! $NPM_STRICT_SSL
|
||||||
|
then
|
||||||
|
NPM_REGISTRY_SCHEME="http"
|
||||||
|
fi
|
||||||
|
|
||||||
# Allow registry.npmjs.org to be overridden with an environment variable
|
# Allow registry.npmjs.org to be overridden with an environment variable
|
||||||
printf "//%s/:_authToken=%s\\nregistry=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "$NPM_REGISTRY_URL" > "$NPM_CONFIG_USERCONFIG"
|
printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "${NPM_REGISTRY_SCHEME}://$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG"
|
||||||
|
|
||||||
chmod 0600 "$NPM_CONFIG_USERCONFIG"
|
chmod 0600 "$NPM_CONFIG_USERCONFIG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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' ]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user