-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 97e1081
Showing
5 changed files
with
168 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,13 @@ | ||
FROM alpine:3.11.0 | ||
|
||
LABEL "maintainer"="George Suaridze" | ||
LABEL "com.github.actions.name"="upload-to-bintray-github-action" | ||
LABEL "com.github.actions.description"="Upload files to JFrog Bintray" | ||
LABEL "com.github.actions.icon"="upload" | ||
LABEL "com.github.actions.color"="green" | ||
|
||
RUN apk --no-cache add curl jq | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 George Suaridze | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,32 @@ | ||
# upload-to-bintray-github-action | ||
|
||
Github action to upload files to JFrog Bintray via the [Bintray REST API](https://bintray.com/docs/api/). | ||
|
||
|
||
## Example | ||
|
||
``` | ||
name: Example | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Upload package to Bintray | ||
uses: masofcon/upload-to-bintray-github-action@master | ||
with: | ||
source_path: ./path/to/package.zip | ||
api_user: example-user | ||
api_key: ${{ secrets.BINTRAY_API_KEY }} # An API key can be obtained from the user profile page. | ||
repository: my_repository | ||
package: example-package | ||
version: '1.0' | ||
upload_path: path/in/repo | ||
publish: 1 | ||
explode: 1 | ||
override: 0 | ||
``` |
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,57 @@ | ||
name: 'upload-to-bintray-github-action' | ||
description: 'Upload files to JFrog Bintray' | ||
branding: | ||
icon: 'upload' | ||
color: 'green' | ||
inputs: | ||
source_path: | ||
description: 'Path to the file that should be uploaded' | ||
required: true | ||
api_url: | ||
description: 'URL of the Bintray API server' | ||
required: false | ||
default: 'https://api.bintray.com' | ||
api_user: | ||
description: 'Username for API usage' | ||
required: true | ||
api_key: | ||
description: 'Key for API usage, it can be obtained from the user profile page' | ||
required: true | ||
repository: | ||
description: 'Name of the repository' | ||
required: true | ||
package: | ||
description: 'Name of the package' | ||
required: true | ||
version: | ||
description: 'Version of the package' | ||
required: true | ||
upload_path: | ||
description: 'Upload path at Bintray site. Some repository layouts require this. Does not need leading or trailing slashes.' | ||
required: false | ||
default: '/' | ||
publish: | ||
description: 'Whether to publish the package right away, use "true" to enable' | ||
required: false | ||
default: 'false' | ||
explode: | ||
description: 'Whether to explode archive, use "1" to enable' | ||
required: false | ||
default: '0' | ||
override: | ||
description: 'Whether to override, use "1" to enable' | ||
required: false | ||
default: '0' | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.repository }} | ||
- ${{ inputs.package }} | ||
- ${{ inputs.version }} | ||
- ${{ inputs.source_path }} | ||
- ${{ inputs.upload_path }} | ||
- ${{ inputs.explode }} | ||
- ${{ inputs.override }} | ||
- ${{ inputs.publish }} |
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,45 @@ | ||
#!/bin/sh | ||
|
||
REPOSITORY=$1 | ||
PACKAGE=$2 | ||
VERSION=$3 | ||
SOURCE_PATH=$4 | ||
UPLOAD_PATH=$5 | ||
EXPLODE=$6 | ||
OVERRIDE=$7 | ||
PUBLISH=$8 | ||
|
||
UPLOADED=0 | ||
for FILE in ${SOURCE_PATH}; do | ||
UPLOAD_URL=${INPUT_API_URL}/content/${INPUT_API_USER}/${REPOSITORY}/${UPLOAD_PATH}/$(basename $FILE) | ||
echo "=== Uploading ${FILE} to ${UPLOAD_URL}" | ||
RESULT=$(curl -T ${FILE} \ | ||
-u${INPUT_API_USER}:${INPUT_API_KEY} \ | ||
-H "X-Bintray-Package:${PACKAGE}" \ | ||
-H "X-Bintray-Version:${VERSION}" \ | ||
-H "X-Bintray-Override:${OVERRIDE}" \ | ||
-H "X-Bintray-Explode:${EXPLODE}" \ | ||
${UPLOAD_URL}) | ||
|
||
if [ "$(echo ${RESULT} | jq -r '.message')" != "success" ]; then | ||
echo "=== Failed to upload ${FILE} with response: ${RESULT}" | ||
exit 1 | ||
else | ||
UPLOADED=$((UPLOADED+1)) | ||
echo "=== ${FILE} uploaded successfully" | ||
fi | ||
done | ||
|
||
if [ "$PUBLISH" == "true" ]; then | ||
echo "=== Publishing repository [${REPOSITORY}] - package [${PACKAGE}] - version [${VERSION}]" | ||
PUBLISH_RESULT=$(curl -X POST \ | ||
-u${INPUT_API_USER}:${INPUT_API_KEY} \ | ||
${INPUT_API_URL}/content/${INPUT_API_USER}/${REPOSITORY}/${PACKAGE}/${VERSION}/publish) | ||
|
||
if [ $(echo ${PUBLISH_RESULT} | jq -r '.files') -lt ${UPLOADED} ]; then | ||
echo "=== Not all files are published successfully, response: ${PUBLISH_RESULT}" | ||
exit 1 | ||
else | ||
echo "=== Published successfully" | ||
fi | ||
fi |