This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 3e8a4cb
Showing
8 changed files
with
180 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,72 @@ | ||
name: publish | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/[email protected] | ||
|
||
- name: version | ||
run: | | ||
# Tagged release | ||
if [[ ${{ github.ref }} == refs/tags/* ]]; then | ||
# Strip git ref prefix from $VERSION | ||
TAGNAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
VERSION=$(echo $TAGNAME | sed -e 's/^v//') | ||
else | ||
VERSION=${{ github.sha }} | ||
fi | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "GITHUB_REF=$GITHUB_REF" >> $GITHUB_ENV | ||
# write .env to export ENV VARIABLES as artifacts for use in other workflow_run runs | ||
echo "PUBLISH_VERSION=$VERSION" >> .env | ||
echo "PUBLISH_GITHUB_REF=$GITHUB_REF" >> .env | ||
echo "Version: $VERSION" | ||
export DOCKER_BUILDKIT=1 | ||
- name: publish | ||
run: | | ||
VERSION="${{ env.VERSION }}" | ||
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | ||
# build and run the docker images | ||
docker-compose -f docker-compose.build.yml up --no-start | ||
# get all built IDs | ||
IMAGE_IDs=$(docker-compose -f docker-compose.build.yml images -q) | ||
echo "IMAGE_IDs: $IMAGE_IDs" | ||
while read -r IMAGE_ID; do | ||
echo "IMAGE_ID: $IMAGE_ID" | ||
# get the name label | ||
NAME=$(basename ${{ github.repository }}).$(docker inspect --format '{{ index .Config.Labels.name }}' $IMAGE_ID) | ||
PUSH="docker.pkg.github.com/${{ github.repository }}/$NAME:$VERSION" | ||
# tag and push | ||
docker tag $IMAGE_ID $PUSH | ||
docker push $PUSH | ||
done <<< "$IMAGE_IDs" | ||
# Upload reference as artifact to pass to deploy | ||
- name: upload .env | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: env | ||
path: .env |
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,8 @@ | ||
ARG VERSION="0.2.9" | ||
|
||
FROM jrasell/levant:${VERSION} as deploy | ||
LABEL name="deploy" | ||
|
||
ADD 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 Penn Signals | ||
|
||
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,16 @@ | ||
# Levant Deploy | ||
|
||
A GitHub Action that finds all nomad jobs and deploys them | ||
## Features | ||
|
||
Searches all subdirectories accoring to `config`. All matched files will be rendered and deployed to Nomad. | ||
|
||
## Example Usage | ||
``` | ||
- name: deploy | ||
uses: pennsignals/[email protected] | ||
with: | ||
versiob: '0.2.6-rc.1' # required | ||
config: './deploy_config.yml' # required | ||
``` |
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 @@ | ||
# action.yml | ||
name: "Levant Deploy" | ||
author: "Darryl Mendillo" | ||
description: "Template and deploy all nomad jobs matching regex in config" | ||
branding: | ||
icon: "database" | ||
color: "red" | ||
inputs: | ||
version: | ||
description: "Release version (tag)" | ||
required: true | ||
config: | ||
description: "deploy_config.yml file with all deployment settings" | ||
required: true | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
args: | ||
- ${{ inputs.version }} | ||
- ${{ inputs.config }} |
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,6 @@ | ||
version: "3.8" | ||
|
||
services: | ||
|
||
deploy: | ||
build: . |
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,12 @@ | ||
version: "3.8" | ||
|
||
services: | ||
|
||
deploy: | ||
build: . | ||
environment: | ||
- INPUT_CONFIG=deploy_config.yml | ||
- INPUT_VERSIOB=1.0.0 | ||
volumes: | ||
- ./:/source | ||
working_dir: /source |
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,24 @@ | ||
#!/bin/sh | ||
|
||
# echo all the variabls | ||
echo "INPUT_ADDR: $INPUT_VERSION" | ||
echo "INPUT_CONFIG: $INPUT_CONFIG" | ||
|
||
# use levant to deploy service nomad jobs as templates | ||
for dir in */ ; do | ||
if [ -d "${dir}nomad" ]; then | ||
|
||
echo "Deploying jobs from: ${dir}nomad." | ||
for file in ${dir}nomad/*; do | ||
matched=$([[ $file =~ ^.*.nomad.hcl$ ]] && echo "true" || echo "false") | ||
|
||
# only deploy *.nomad.hcl (jobs) | ||
if [ $matched = "true" ]; then | ||
echo "levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file}" | ||
levant render -var TAG=${INPUT_VERSION} -var DEPLOY=staging -var-file=${INPUT_CONFIG} -out=nomad/$(basename $file) ${file} | ||
levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file} | ||
fi | ||
|
||
done | ||
fi | ||
done |