From 50b655b1f0a75ff2ed88ee9134e867a84e492f5b Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 17:47:15 -0800 Subject: [PATCH 01/15] BB-762 upgrading pip isn't necessary --- entrypoint.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index e403f46..ca11766 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -12,7 +12,6 @@ release=$7 apt-get -y update apt-get -y install python-pip -pip install --upgrade pip pip install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From debca01dcaec52eba520a8666b08f8b89acacce9 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 17:58:34 -0800 Subject: [PATCH 02/15] BB-762 building on any branch now --- .github/workflows/main.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a376aa4..efccb65 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,12 +1,7 @@ name: Cloudsmith Push -on: - push: - branches: - - master - tags: - - '*' +on: push jobs: - push-file: + push: runs-on: ubuntu-latest name: Push demo steps: From 02d341ee421b850266931b12dd4db5613aae0847 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 18:07:36 -0800 Subject: [PATCH 03/15] BB-762 trying pip3 --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ca11766..d1b26c2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,7 +11,7 @@ distro=$6 release=$7 apt-get -y update -apt-get -y install python-pip -pip install cloudsmith-cli +apt-get -y install python-pip3 +pip3 install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From c31b42734e129d746242bd8bcf0cb55f29374b92 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 18:09:18 -0800 Subject: [PATCH 04/15] BB-762 syntax error --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index d1b26c2..801b7d4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,7 +11,7 @@ distro=$6 release=$7 apt-get -y update -apt-get -y install python-pip3 +apt-get -y install python3-pip pip3 install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From d4e753ab4d7e9a5505d5112c2d475a8d40c50c56 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 19:27:57 -0800 Subject: [PATCH 05/15] BB-762 changing version to story branch --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efccb65..ef51c0a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: steps: - name: Push id: push - uses: AutoModality/action-cloudsmith@master + uses: AutoModality/action-cloudsmith@BB-762 with: command: 'push' format: 'deb' From b5787feeeabee89dc1735f80daaf8678b9947770 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 19:37:55 -0800 Subject: [PATCH 06/15] BB-762 trying ubuntu 18 --- Dockerfile | 2 +- entrypoint.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index cae1cb6..bab8e48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Container image that runs your code -FROM ubuntu:xenial +FROM ubuntu:18.10 # Copies your code file from your action repository to the filesystem path `/` of the container COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index 801b7d4..761407c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,8 +10,6 @@ file=$5 distro=$6 release=$7 -apt-get -y update -apt-get -y install python3-pip pip3 install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From ae0b25678420a54b2972d62cc4493d5aa22e6c3a Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 19:49:34 -0800 Subject: [PATCH 07/15] BB-762 installing pip3 --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 761407c..ba1e68a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,8 @@ file=$5 distro=$6 release=$7 +sudo apt update +sudo apt install python3-pip pip3 install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From 05b58518e45c5364228a0ac202e9b5fee7a863fe Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 19:56:25 -0800 Subject: [PATCH 08/15] BB-762 no sudo allowd --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ba1e68a..dd2d55e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,8 +10,8 @@ file=$5 distro=$6 release=$7 -sudo apt update -sudo apt install python3-pip +apt -y update +apt -y install python3-pip pip3 install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From 5dfa956d08f0b3961c1fca389b25b7356370c5b8 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 20:06:03 -0800 Subject: [PATCH 09/15] BB-762 back to python 2 --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index dd2d55e..ca11766 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,8 +10,8 @@ file=$5 distro=$6 release=$7 -apt -y update -apt -y install python3-pip -pip3 install cloudsmith-cli +apt-get -y update +apt-get -y install python-pip +pip install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From 3450f9bce17dbfd298a417f118b16c55ad741bf0 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 20:11:17 -0800 Subject: [PATCH 10/15] BB-762 trying python image --- Dockerfile | 2 +- entrypoint.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bab8e48..556e7aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Container image that runs your code -FROM ubuntu:18.10 +FROM python:3.8-slim # Copies your code file from your action repository to the filesystem path `/` of the container COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index ca11766..9550f35 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,8 +10,6 @@ file=$5 distro=$6 release=$7 -apt-get -y update -apt-get -y install python-pip pip install cloudsmith-cli # requires a CLOUDSMITH_API_KEY env variable to push cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file From 28eac18186109b8604bf57dd14b8cee9eb8da6be Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 20:56:18 -0800 Subject: [PATCH 11/15] BB-762 ready to send the command for real --- entrypoint.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9550f35..20e5f8a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,24 @@ file=$5 distro=$6 release=$7 -pip install cloudsmith-cli + # requires a CLOUDSMITH_API_KEY env variable to push -cloudsmith push $action $format $org/$repo/distro/release some-file.deb \ No newline at end of file +if [[ -z $CLOUDSMITH_API_KEY ]]; then + echo "CLOUDSMITH_API_KEY is required" + exit 1 +fi + +if [[ "$command" != "push" ]]; then + echo "command $comand not yet implemented." + exit 3 +fi + +pip install cloudsmith-cli + + +if [[ "$format" == "deb" ]]; then + cloudsmith push $action $format $org/$repo/$distro/$release $file +else + echo "format $format not yet implemented." + exit 2 +fi From 99f7dbb0c5ef638157132b2aab8af64f5b180fef Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 21:08:25 -0800 Subject: [PATCH 12/15] BB-762 maybe not bash so [[ not recognized --- README.md | 43 ++++++++++++++++++++++++++++--------------- entrypoint.sh | 2 +- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 99cbdd8..e76b305 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,37 @@ Interact with Cloudsmith repositories using the cloudmsith cli to push packages, etc. -## Inputs +## Cloudsmith CLI +This action uses the Cloudsmith CLI and intends to be as similar +to its structure and terminology as possible. -### `who-to-greet` +**Implemented** +* Push + * Debian format -**Required** The name of the person to greet. Default `"World"`. +**Not Implemented** +* Everything else -## Outputs - -### `time` - -The time we greeted you. - -### `os` - -The operating system that ran the action. ## Example usage -uses: actions/hello-world-docker-action@v1 -with: - who-to-greet: 'Mona the Octocat' \ No newline at end of file +``` +name: Cloudsmith Push +on: push +jobs: + push: + runs-on: ubuntu-latest + name: Push demo + steps: + - name: Push + id: push + uses: AutoModality/action-cloudsmith@BB-762 + with: + command: 'push' + format: 'deb' + owner: 'automodality' + repo: 'trial' + distro: 'ubuntu' + release: 'xenial' + file: 'cool-lib_1.0.1_amd64.deb' +``` \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 20e5f8a..af40f3f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e #exit on error From 98e0a230610856928ce1fe8718ac53112e8e7747 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 21:18:15 -0800 Subject: [PATCH 13/15] BB-762 added the api key --- .github/workflows/main.yml | 1 + README.md | 4 ++++ action.yml | 4 ++++ entrypoint.sh | 15 ++++++++------- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef51c0a..015e091 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,7 @@ jobs: id: push uses: AutoModality/action-cloudsmith@BB-762 with: + api-key: ${{ secrets.CLOUDSMITH_API_KEY }} command: 'push' format: 'deb' owner: 'automodality' diff --git a/README.md b/README.md index e76b305..39229fe 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ to its structure and terminology as possible. **Not Implemented** * Everything else +## Cloudsmith API Key + +The API key is required for the cloudsmith-cli to work. +Add a secret in the settings of your repository named `CLOUDSMITH_API_KEY`. ## Example usage diff --git a/action.yml b/action.yml index d09ec76..a911f30 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,9 @@ name: 'Cloudsmith' description: 'Interact with Cloudsmith repositories' inputs: + api-key: + description: 'The Cloudsmith API Key in the Github Secrets repository settings.' + required: true command: description: 'The desired action with cloudsmith (push, list, etc)' required: true @@ -29,6 +32,7 @@ runs: using: 'docker' image: 'Dockerfile' args: # these map in order with entrypoint.sh + - ${{ inputs.api-key }} - ${{ inputs.command }} - ${{ inputs.format }} - ${{ inputs.owner }} diff --git a/entrypoint.sh b/entrypoint.sh index af40f3f..59083f1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,13 +2,14 @@ set -e #exit on error -command=$1 -format=$2 -org=$3 -repo=$4 -file=$5 -distro=$6 -release=$7 +api_key=$1 +command=$2 +format=$3 +org=$4 +repo=$5 +file=$6 +distro=$7 +release=$8 # requires a CLOUDSMITH_API_KEY env variable to push From 1ef3dc574b1599b828c975948ad2008fc74a2600 Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 21:28:08 -0800 Subject: [PATCH 14/15] BB-762 forgot to handle key properly --- entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 59083f1..231a3db 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,11 +13,13 @@ release=$8 # requires a CLOUDSMITH_API_KEY env variable to push -if [[ -z $CLOUDSMITH_API_KEY ]]; then +if [[ -z $api_key ]]; then echo "CLOUDSMITH_API_KEY is required" exit 1 fi +export CLOUDSMITH_API_KEY=$api_key + if [[ "$command" != "push" ]]; then echo "command $comand not yet implemented." exit 3 From 5b3ac2d4bf5644b9d3dd8e33c90d65328a7efb4b Mon Sep 17 00:00:00 2001 From: Aaron Roller Date: Sun, 29 Dec 2019 21:35:45 -0800 Subject: [PATCH 15/15] BB-762 picked a file I know will exist --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 015e091..8b5179d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,5 +16,5 @@ jobs: repo: 'trial' distro: 'ubuntu' release: 'xenial' - file: 'action.yml' + file: '/bin/bash' #real file, but wrong format