-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kat Cosgrove
committed
Oct 31, 2019
0 parents
commit b3cb51a
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Container image | ||
FROM alpine:3.10 | ||
|
||
## Copy code from your action repository to the filesystem path `/` in the container | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
## Disallow storing credentials | ||
ENV JFROG_CLI_OFFER_CONFIG=false | ||
|
||
## Install cURL, get the JFrog CLI, and make the script executable | ||
RUN apk update &&\ | ||
yes | apk add curl &&\ | ||
rm -rf /var/lib/apt/lists/* &&\ | ||
curl -fL https://getcli.jfrog.io | sh &&\ | ||
mv jfrog /bin &&\ | ||
chmod +x entrypoint.sh &&\ | ||
mv entrypoint.sh /bin | ||
|
||
## When the container starts, run the entrypoint script | ||
ENTRYPOINT ["entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# JFrog CLI for GitHub Actions v2 | ||
|
||
This action provides a wrapper around the [JFrog CLI](https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory). It will execute whatever CLI commands your workflow defines, and can use any of the three authentication methods available to the CLI. | ||
|
||
This action only supports [JFrog Artifactory](https://jfrog.com/artifactory/) commands at this time. | ||
|
||
## Usage | ||
|
||
This action requires several environment variables to operate: the URL for your Artifactory instance, the type of authentication you wish to use, and the credentials for your authentication method. | ||
|
||
### Required Variables | ||
|
||
| Variable | Value | | ||
| ------------- |:-------------:| | ||
| AUTH | apikey, username, or accesstoken | | ||
| URL | The URL for your Artifactory instance | | ||
|
||
### Authentication Variables | ||
|
||
| Auth Method | Variable | | ||
| ------------- |:-------------:| | ||
| API Key | APIKEY | | ||
| Access Token | TOKEN | | ||
| Login Credentials | USER and PASS | | ||
|
||
**All environment variables other than AUTH should be set as secrets.** | ||
|
||
## Example Workflow | ||
|
||
The following workflow simply pings your defined Artifactory instance to confirm it is operational. It uses the API key authentication method. | ||
|
||
``` | ||
name: JFrog CLI | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Ping Artifactory | ||
uses: katcosgrove/jfrog-actions@master | ||
with: | ||
cmd: 'ping' | ||
env: | ||
auth: ${{ secrets.AUTH }} | ||
apikey: ${{ secrets.APIKEY }} | ||
url: ${{ secrets.URL }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'JFrog CLI for Artifactory' | ||
author: 'Kat Cosgrove' | ||
branding: | ||
icon: 'codepen' | ||
color: 'green' | ||
description: 'Runs a JFrog CLI for Artifactory command.' | ||
image: 'Dockerfile' | ||
inputs: | ||
cmd: | ||
description: 'The command you want to run, without `jfrog rt`' | ||
required: true | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.cmd }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ $auth = "username" ]; | ||
then | ||
sh -c "jfrog rt config --interactive=false --enc-password=true --url=$url --user=$user --password=$pass" | ||
elif [ $auth = "apikey" ]; | ||
then | ||
sh -c "jfrog rt config --interactive=false --enc-password=true --url=$url --apikey=$apikey" | ||
elif [ $auth = "accesstoken" ]; | ||
then | ||
sh -c "jfrog rt config --interactive=false --enc-password=true --url=$url --access-token=$token" | ||
else | ||
echo "Error: Authentication mode must be set!"; | ||
fi | ||
|
||
for cmd in "$@"; do | ||
echo "Running: '$cmd'" | ||
if sh -c "jfrog rt $cmd"; then | ||
echo "Success!" | ||
else | ||
exit_code=$? | ||
echo "Failure: '$cmd' exited with $exit_code" | ||
exit $exit_code | ||
fi | ||
done |