Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nightly tag #368

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions jaws-journey-deploy/orb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,17 @@ commands:
include ./scripts/github_docker_login.sh
name: Github Docker Repo Login

create-nightly-tag:
parameters:
token:
type: string
steps:
- run:
name: Create nightly tag
shell: /bin/bash -eo pipefail
command: |
include ./scripts/create_nightly_tag.sh

tf:
parameters:
<<: *tf-common-parameters
Expand Down Expand Up @@ -1102,3 +1113,16 @@ jobs:
steps:
- slack/notify:
<<: *slack-notification

create-nightly-tag:
parameters:
token:
type: string
machine:
docker_layer_caching: false
working_directory: ~/working
steps:
- attach_workspace:
at: ~/working
- create-nightly-tag:
token: << parameters.token >>
2 changes: 1 addition & 1 deletion jaws-journey-deploy/orb_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ovotech/[email protected].18
ovotech/[email protected].19
24 changes: 24 additions & 0 deletions jaws-journey-deploy/scripts/create_nightly_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e
GITHUB_BOT_TOKEN="<< parameters.token >>"

if [[ -z "$GITHUB_BOT_TOKEN" ]] ; then
echo "GITHUB_BOT_TOKEN was not set at input (second argument)"
exit 1
fi

URL_BASE="https://api.github.com/repos/ovotech/${CIRCLE_PROJECT_REPONAME}"
AUTH_HEADER="Authorization: Bearer $GITHUB_BOT_TOKEN"
TAG_NAME="nightly-$(date +"%Y-%m-%d")"
echo "TAG_NAME $TAG_NAME"

COMMIT_RESPONSE=$(curl --silent --show-error --fail --request GET "${URL_BASE}/commits/master" --header "$AUTH_HEADER") || exit
COMMIT_SHA=$(echo "$COMMIT_RESPONSE" | jq -r '.sha')
echo "Latest commit on master: $COMMIT_SHA"

TAG_REQUEST="{\"tag\": \"$TAG_NAME\", \"object\": \"$COMMIT_SHA\", \"type\":\"commit\", \"message\":\"Nightly automation test\"}"
TAG_RESPONSE=$(curl -sSf --request POST "${URL_BASE}/git/tags" --header "$AUTH_HEADER" --header 'Content-Type: application/json' --data "$TAG_REQUEST") || exit
TAG_SHA=$(echo "$TAG_RESPONSE" | jq -r '.sha')

REF_REQUEST="{\"ref\": \"refs/tags/$TAG_NAME\", \"sha\": \"$TAG_SHA\"}"
curl --fail --request POST "${URL_BASE}/git/refs" --header "$AUTH_HEADER" --header 'Content-Type: application/json' --data "$REF_REQUEST"