Skip to content

Commit

Permalink
ci: adds a manual deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Sep 30, 2022
1 parent 36c4125 commit 080aa00
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/manual-deploy-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Manual Deploy to Testing

on:
workflow_dispatch:
inputs:
tag:
description: tag
required: true

env:
environment: testing

jobs:
deploy:
name: Deploy ${{ github.event.inputs.tag }} to testing
runs-on: ubuntu-latest
environment: testing
steps:
- name: Clone latest repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check that the tag exists in repo
id: tag_check
run: |
if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then
echo '::set-output name=tag::${{ github.event.inputs.tag }}'
elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then
echo "::set-output name=tag::`git rev-parse '${{ github.event.inputs.tag }}'`"
else
echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}"
echo "Aborting deployment."
false
fi
- name: Log into Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check that the tag exists in container registry
id: image_check
run: |
if docker manifest inspect ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then
echo '::set-output name=image_exists::true'
echo "image exists!"
else
echo "image doesn't exist; Starting to Build and push image"
fi
- name: Checkout Correct repository
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.tag }}
- name: Build and Push
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.prod
push: true
tags: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}}
- name: Deploy to ${{ env.environment }}
uses: mlibrary/deploy-to-kubernetes@v3
with:
registry_token: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }}
cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }}
cluster_server: https://hatcher.kubernetes.lib.umich.edu
namespace_token: ${{ secrets.HATCHER_TOKEN }}
namespace: ${{ secrets.NAMESPACE }}
resource_name: report-web
container: report-web

0 comments on commit 080aa00

Please sign in to comment.