Skip to content

Commit

Permalink
Replace most github actions with scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Lubken committed Sep 20, 2024
1 parent 4f3d2eb commit a93a3dd
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 187 deletions.
82 changes: 39 additions & 43 deletions {{cookiecutter.name}}/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% raw %}name: release

on:
release:
types:
Expand All @@ -15,39 +14,39 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: publish
id: publish
uses: pennsignals/[email protected]
with:
docker_compose: "docker-compose.yml"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
- id: version
run: |
version=$(./scripts/version.sh)
echo "version = ${version}"
echo "version=${version}" >> $GITHUB_OUTPUT

- id: publish
run: |
./scripts/publish.sh -b true -p "${{ secrets.GITHUB_TOKEN }}" -v "${{ steps.version.outputs.version }}"

staging:
evaluation:
if: ${{ github.event.release.prerelease }}
needs: publish
runs-on: [self-hosted, nomad, azure, staging]
runs-on: [evaluation, self-hosted, nomad, azure]

steps:
- name: checkout
uses: actions/checkout@v4

# Deploy pre-release to staging
- name: staging_consul
uses: pennsignals/[email protected]
with:
addr: "${{ secrets.STAGING_CONSUL_ADDR }}"
config: "./local/deploy_config.yml"
env: "staging"

- name: staging_deploy
uses: pennsignals/[email protected]
with:
version: "${{ needs.publish.outputs.tag }}"
config: "./local/deploy_config.yml"
nomad_addr: "${{ secrets.STAGING_NOMAD_ADDR }}"

- name: tar
run: tar -czvf nomad.tar.gz nomad/
# Deploy configuration
- id: consul
run: |
./scripts/consul.sh \
--src ./predict/local/configuration.yaml \
--dst pennsignals/palliativeconnect/predict/configuration.yaml

# Deploy jobs
- id: nomad
run: |
./scripts/nomad.sh \
--src ./predict/nomad \
--dst ./nomad \
--version "${{ needs.publish.outputs.version }}"

# Upload rendered nomad jobs as artifacts
- name: upload
Expand All @@ -74,23 +73,20 @@ jobs:
- name: checkout
uses: actions/checkout@v4

# Deploy main release to Production
- name: production_consul
uses: pennsignals/[email protected]
with:
addr: "${{ secrets.PRODUCTION_CONSUL_ADDR }}"
config: "./local/deploy_config.yml"
env: "production"

- name: production_deploy
uses: pennsignals/[email protected]
with:
version: "${{ needs.publish.outputs.tag }}"
config: "./local/deploy_config.yml"
nomad_addr: "${{ secrets.PRODUCTION_NOMAD_ADDR }}"

- name: tar
run: tar -czvf nomad.tar.gz nomad/
# Deploy configuration
- id: consul
run: |
./scripts/consul.sh \
--src ./predict/local/configuration.yaml \
--dst pennsignals/palliativeconnect/predict/configuration.yaml

# Deploy jobs
- id: nomad
run: |
./scripts/nomad.sh \
--src ./predict/nomad
--dst ./nomad \
--version "${{ needs.publish.outputs.version }}"

# Upload rendered nomad jobs as artifacts
- name: upload
Expand Down
58 changes: 0 additions & 58 deletions {{cookiecutter.name}}/docker-compose.deploy.yml

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions {{cookiecutter.name}}/local/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions {{cookiecutter.name}}/local/config.env

This file was deleted.

33 changes: 0 additions & 33 deletions {{cookiecutter.name}}/local/deploy_config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion {{cookiecutter.name}}/predict/nomad/backfill.nomad.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ job "{{ cookiecutter.name }}_backfill" {

task "predict" {
config = {
image = "[[ .services.predict.image.registry ]]/[[ .services.predict.image.name ]]:[[ or (.TAG) .services.predict.image.version ]]"
image = "{{ cookiecutter.registry }}/{{ cookiecutter.organization }}/{{ cookiecutter.name }}/{{ cookiecutter.name }}.predict:[[ (.version) ]]"
dns_servers = ["127.0.0.1", "170.212.249.133", "170.212.24.5"]
dns_search_domains = ["uphs.upenn.edu", "infoblox-master.uphs.upenn.edu", "root.uphs.upenn.edu"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ job "{{ cookiecutter.name }}_flowsheets" {
task "flowsheets" {
config = {
command = "publish-flowsheets"
image = "{{ cookiecutter.registry}}/{{ cookiecutter.name }}:[[ or (.TAG) .services.predict.image.version ]]"
image = "{{ cookiecutter.registry}}/{{ cookiecutter.name }}:[[ (.version) ]]"
dns_servers = ["127.0.0.1", "170.212.249.133", "170.212.24.5"]
dns_search_domains = ["uphs.upenn.edu", "infoblox-master.uphs.upenn.edu", "root.uphs.upenn.edu"]

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.name}}/predict/nomad/predict.nomad.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ job "{{ cookiecutter.name }}_predict" {

task "predict" {
config = {
image = "{{ cookiecutter.registry }}/[[ .services.predict.image.name ]]:[[ or (.TAG) .services.predict.image.version ]]"
image = "{{ cookiecutter.registry }}/{{ cookiecutter.name }}.predict:[[ (.version) ]]"

volumes = [
"/share/models/{{ cookiecutter.name }}:/model:ro"
Expand Down
35 changes: 35 additions & 0 deletions {{cookiecutter.name}}/scripts/consul.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euxo pipefail

function usage {
echo ""
echo "Consul configuration put."
echo ""
echo "usage: --src ./predict/local/configuration.yaml --dst organization/application/predict/configuration.yaml"
echo ""
echo " --src -s string path to configuration file"
echo " --dst -d string path to consul kv"
echo " --help -t Print usage and exit"
echo ""
}

while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-d|--dst)
dst="$2"
;;
-s|--src)
src="$2"
;;
*)
invalid_parameter $1
esac
shift
shift
done

consul kv put ${dst} @${src}
54 changes: 54 additions & 0 deletions {{cookiecutter.name}}/scripts/nomad.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -euxo pipefail

function usage {
echo ""
echo "Publish labeled images from docker compose."
echo ""
echo "usage: --src -s ./predict/nomad --dst -d ./nomad"
echo ""
echo " --src -s string Source directory for nomad files"
echo " --dst -d string Destination for rendered nomad files"
echo " --version -v string version"
echo " (example: 4.0.0-rc.1)"
echo " --help -h Print usage and exit"
echo ""
}

while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-s|--src)
src="$2"
;;
-d|--dst)
dst="$2"
;;
-v|--version)
version="$2"
;;
*)
invalid_parameter $1
esac
shift
shift
done

echo "Deploying jobs from: ${src}"
for file in ${src}/*.nomad.hcl; do
name="$(basename ${file})"
levant render -var version="${version}" -out="${dst}/${name}" ${file}
done

echo "Deploying jobs from: ${dst}."
for file in ${src}/*.nomad.hcl; do
levant deploy \
-address http://nomad.service.consul:4646 \
-var version="${version}" \
-ignore-no-changes ${file}
done

tar -czvf nomad.tar.gz ${dst}
Loading

0 comments on commit a93a3dd

Please sign in to comment.