-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Github action workflows (#497)
* Runs tests automatically * Uploads release artifacts automatically
- Loading branch information
Showing
5 changed files
with
104 additions
and
10 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,55 @@ | ||
#!/bin/bash | ||
# based on: https://github.com/skx/github-action-publish-binaries/blob/master/upload-script | ||
# | ||
# Upload binary artifacts when a new release is made. | ||
# | ||
|
||
set -e | ||
|
||
# Ensure that the GITHUB_TOKEN secret is included | ||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Set the GITHUB_TOKEN env variable." | ||
exit 1 | ||
fi | ||
|
||
# Ensure that the file path is present | ||
if [[ -z "$1" ]]; then | ||
echo "Missing file (pattern) to upload." | ||
exit 1 | ||
fi | ||
|
||
# Only upload to non-draft releases | ||
IS_DRAFT=$(jq --raw-output '.release.draft' $GITHUB_EVENT_PATH) | ||
if [ "$IS_DRAFT" = true ]; then | ||
echo "This is a draft, so nothing to do!" | ||
exit 0 | ||
fi | ||
|
||
# Run the build-script | ||
make docker-build | ||
docker container create --name rita quay.io/activecm/rita:latest | ||
docker container cp rita:/rita ./rita | ||
|
||
# Prepare the headers | ||
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" | ||
|
||
# Build the Upload URL from the various pieces | ||
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH) | ||
|
||
# For each matching file | ||
for file in $*; do | ||
echo "Processing file ${file}" | ||
|
||
FILENAME=$(basename ${file}) | ||
UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}" | ||
echo "$UPLOAD_URL" | ||
|
||
# Upload the file | ||
curl \ | ||
-sSL \ | ||
-XPOST \ | ||
-H "${AUTH_HEADER}" \ | ||
--upload-file "${file}" \ | ||
--header "Content-Type:application/octet-stream" \ | ||
"${UPLOAD_URL}" | ||
done |
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,15 @@ | ||
name: Upload files to new release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
upload: | ||
name: Upload Artifacts | ||
runs-on: ubuntu-16.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: .github/release.sh rita install.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
name: Rita tests | ||
|
||
on: | ||
pull_request: | ||
# Run tests except if only markdown files are changed | ||
paths: | ||
- '*' | ||
- '!*.md' | ||
|
||
jobs: | ||
test: | ||
name: static and unit tests | ||
runs-on: ubuntu-16.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: make docker-test | ||
|
||
# integration: | ||
# name: integration tests | ||
# runs-on: ubuntu-16.04 | ||
# steps: | ||
# - uses: actions/checkout@v1 | ||
# - run: | | ||
# make docker-build-test | ||
# docker container create --name rita --entrypoint /bin/sleep quay.io/activecm/rita:test 5m | ||
# docker container start rita | ||
# docker container exec rita tar cf vendor.tar vendor | ||
# docker container cp rita:/go/src/github.com/activecm/rita/rita ./rita | ||
# docker container cp rita:/go/src/github.com/activecm/rita/vendor.tar ./vendor.tar | ||
# docker container stop rita | ||
# tar xf vendor.tar | ||
# - run: make integration-test |
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
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