Skip to content

Commit e292d09

Browse files
author
Aaron Roller
authored
BB-762 Cloudsmith Action ready for pushing debian files (#1)
* BB-762 upgrading pip isn't necessary * BB-762 building on any branch now * BB-762 trying pip3 * BB-762 syntax error * BB-762 changing version to story branch * BB-762 trying ubuntu 18 * BB-762 installing pip3 * BB-762 no sudo allowd * BB-762 back to python 2 * BB-762 trying python image * BB-762 ready to send the command for real * BB-762 maybe not bash so [[ not recognized * BB-762 added the api key * BB-762 forgot to handle key properly * BB-762 picked a file I know will exist
1 parent 44e11f0 commit e292d09

5 files changed

Lines changed: 73 additions & 38 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
name: Cloudsmith Push
2-
on:
3-
push:
4-
branches:
5-
- master
6-
tags:
7-
- '*'
2+
on: push
83
jobs:
9-
push-file:
4+
push:
105
runs-on: ubuntu-latest
116
name: Push demo
127
steps:
138
- name: Push
149
id: push
15-
uses: AutoModality/action-cloudsmith@master
10+
uses: AutoModality/action-cloudsmith@BB-762
1611
with:
12+
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
1713
command: 'push'
1814
format: 'deb'
1915
owner: 'automodality'
2016
repo: 'trial'
2117
distro: 'ubuntu'
2218
release: 'xenial'
23-
file: 'action.yml'
19+
file: '/bin/bash' #real file, but wrong format
2420

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Container image that runs your code
2-
FROM ubuntu:xenial
2+
FROM python:3.8-slim
33

44
# Copies your code file from your action repository to the filesystem path `/` of the container
55
COPY entrypoint.sh /entrypoint.sh

README.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,41 @@
22
Interact with Cloudsmith repositories using the cloudmsith cli
33
to push packages, etc.
44

5-
## Inputs
5+
## Cloudsmith CLI
6+
This action uses the Cloudsmith CLI and intends to be as similar
7+
to its structure and terminology as possible.
68

7-
### `who-to-greet`
9+
**Implemented**
10+
* Push
11+
* Debian format
812

9-
**Required** The name of the person to greet. Default `"World"`.
13+
**Not Implemented**
14+
* Everything else
1015

11-
## Outputs
16+
## Cloudsmith API Key
1217

13-
### `time`
14-
15-
The time we greeted you.
16-
17-
### `os`
18-
19-
The operating system that ran the action.
18+
The API key is required for the cloudsmith-cli to work.
19+
Add a secret in the settings of your repository named `CLOUDSMITH_API_KEY`.
2020

2121
## Example usage
2222

23-
uses: actions/hello-world-docker-action@v1
24-
with:
25-
who-to-greet: 'Mona the Octocat'
23+
```
24+
name: Cloudsmith Push
25+
on: push
26+
jobs:
27+
push:
28+
runs-on: ubuntu-latest
29+
name: Push demo
30+
steps:
31+
- name: Push
32+
id: push
33+
uses: AutoModality/action-cloudsmith@BB-762
34+
with:
35+
command: 'push'
36+
format: 'deb'
37+
owner: 'automodality'
38+
repo: 'trial'
39+
distro: 'ubuntu'
40+
release: 'xenial'
41+
file: 'cool-lib_1.0.1_amd64.deb'
42+
```

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
name: 'Cloudsmith'
33
description: 'Interact with Cloudsmith repositories'
44
inputs:
5+
api-key:
6+
description: 'The Cloudsmith API Key in the Github Secrets repository settings.'
7+
required: true
58
command:
69
description: 'The desired action with cloudsmith (push, list, etc)'
710
required: true
@@ -29,6 +32,7 @@ runs:
2932
using: 'docker'
3033
image: 'Dockerfile'
3134
args: # these map in order with entrypoint.sh
35+
- ${{ inputs.api-key }}
3236
- ${{ inputs.command }}
3337
- ${{ inputs.format }}
3438
- ${{ inputs.owner }}

entrypoint.sh

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e #exit on error
44

5-
command=$1
6-
format=$2
7-
org=$3
8-
repo=$4
9-
file=$5
10-
distro=$6
11-
release=$7
12-
13-
apt-get -y update
14-
apt-get -y install python-pip
15-
pip install --upgrade pip
16-
pip install cloudsmith-cli
5+
api_key=$1
6+
command=$2
7+
format=$3
8+
org=$4
9+
repo=$5
10+
file=$6
11+
distro=$7
12+
release=$8
13+
14+
1715
# requires a CLOUDSMITH_API_KEY env variable to push
18-
cloudsmith push $action $format $org/$repo/distro/release some-file.deb
16+
if [[ -z $api_key ]]; then
17+
echo "CLOUDSMITH_API_KEY is required"
18+
exit 1
19+
fi
20+
21+
export CLOUDSMITH_API_KEY=$api_key
22+
23+
if [[ "$command" != "push" ]]; then
24+
echo "command $comand not yet implemented."
25+
exit 3
26+
fi
27+
28+
pip install cloudsmith-cli
29+
30+
31+
if [[ "$format" == "deb" ]]; then
32+
cloudsmith push $action $format $org/$repo/$distro/$release $file
33+
else
34+
echo "format $format not yet implemented."
35+
exit 2
36+
fi

0 commit comments

Comments
 (0)