Merge pull request #339 from backend-developers-ltd/COM-253-efficient… #5
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: "CD: miner runner (pre-prod)" | |
on: | |
push: | |
branches: | |
- 'deploy-miner-runner-preprod' | |
env: | |
BUILD_DIRECTORY: "miner/envs/runner" | |
TAG_VERSION: "v0-latest" | |
DOCKER_REPO_NAME: "backenddevelopersltd/compute-horde-miner-runner-preprod" | |
DOCKER_NGINX_REPO_NAME: "backenddevelopersltd/compute-horde-miner-nginx-preprod" | |
MINER_IMAGE_REPO: "compute-horde-miner-preprod" | |
MINER_NGINX_IMAGE_REPO: "compute-horde-miner-nginx-preprod" | |
DIST_VERSION_PREFIX: "miner-runner-preprod" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Docker build and push | |
run: | | |
IMAGE_NAME="${DOCKER_REPO_NAME}:${TAG_VERSION}" | |
SHA_IMAGE_NAME="${DOCKER_REPO_NAME}:git-${GITHUB_SHA}" | |
cd "${BUILD_DIRECTORY}" && \ | |
docker build \ | |
-t "${IMAGE_NAME}" \ | |
--build-arg MINER_RUNNER_VERSION="${GITHUB_SHA}" \ | |
--build-arg MINER_IMAGE_REPO="${MINER_IMAGE_REPO}" \ | |
--build-arg MINER_NGINX_IMAGE_REPO="${MINER_NGINX_IMAGE_REPO}" \ | |
. | |
docker image tag "${IMAGE_NAME}" "${SHA_IMAGE_NAME}" | |
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
docker push "${IMAGE_NAME}" | |
docker push "${SHA_IMAGE_NAME}" | |
- name: Docker build and push (nginx) | |
run: | | |
IMAGE_NAME="${DOCKER_NGINX_REPO_NAME}:${TAG_VERSION}" | |
SHA_IMAGE_NAME="${DOCKER_NGINX_REPO_NAME}:git-${GITHUB_SHA}" | |
cd "${BUILD_DIRECTORY}/nginx" && \ | |
docker build \ | |
-t "${IMAGE_NAME}" \ | |
. | |
docker image tag "${IMAGE_NAME}" "${SHA_IMAGE_NAME}" | |
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
docker push "${IMAGE_NAME}" | |
docker push "${SHA_IMAGE_NAME}" | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Set Dist Version | |
run: | | |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" | |
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV | |
- name: Create Tag | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const {DIST_VERSION} = process.env | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${DIST_VERSION}`, | |
sha: context.sha | |
}) |