Version bump #78
Workflow file for this run
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
name: Release New Version | |
on: | |
push: | |
branches: main | |
tags: | |
- v* | |
env: | |
IMAGE_NAME: valid-ator | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Build image | |
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Push image | |
env: | |
TOKEN_VALID_ATOR_LIVE: ${{ secrets.VALID_ATOR_LIVE }} | |
TOKEN_VALID_ATOR_LIVE_MONGO: ${{ secrets.VALID_ATOR_LIVE_MONGO }} | |
TOKEN_VALID_ATOR_LIVE_REDIS: ${{ secrets.VALID_ATOR_LIVE_REDIS }} | |
TOKEN_VALID_ATOR_STAGE: ${{ secrets.VALID_ATOR_STAGE }} | |
TOKEN_VALID_ATOR_STAGE_MONGO: ${{ secrets.VALID_ATOR_STAGE_MONGO }} | |
TOKEN_VALID_ATOR_STAGE_REDIS: ${{ secrets.VALID_ATOR_STAGE_REDIS }} | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "main" ] && VERSION=stage | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
echo -e "{\"deploy\":\"$VERSION\",\"commit_sha\":\"${GITHUB_SHA}\"}" > deploy-vars.json | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
- name: Deploy new version | |
env: | |
NOMAD_CACERT: admin-ui-ca.crt | |
NOMAD_TOKEN: ${{ secrets.VALIDATOR_DEPLOY_SECRET }} | |
NOMAD_ADDR: ${{ secrets.ATOR_DEPLOY_ADDR }} | |
CONSUL_CACERT: admin-ui-ca.crt | |
CONSUL_HTTP_TOKEN: ${{ secrets.VALIDATOR_CONSUL_SERVICE_TOKEN }} | |
CONSUL_ADDR: ${{ secrets.CONSUL_DEPLOY_ADDR }} | |
run: | | |
curl -L https://releases.hashicorp.com/levant/0.3.2/levant_0.3.2_linux_amd64.zip -o levant.zip | |
unzip levant.zip | |
[[ -n $(grep "stage" deploy-vars.json) ]] && ./levant render -var-file="deploy-vars.json" -consul-address=$CONSUL_ADDR -out runtime-job.hcl valid-ator-stage.hcl | |
[[ -z $(grep "stage" deploy-vars.json) ]] && ./levant render -var-file="deploy-vars.json" -consul-address=$CONSUL_ADDR -out runtime-job.hcl valid-ator-live.hcl | |
curl -L https://releases.hashicorp.com/nomad/1.5.6/nomad_1.5.6_linux_amd64.zip -o nomad.zip | |
unzip nomad.zip | |
./nomad job run runtime-job.hcl | |