Skip to content

Commit

Permalink
Add deploy to staging and production
Browse files Browse the repository at this point in the history
  • Loading branch information
daaang committed Sep 11, 2020
1 parent 30f7d41 commit 28f48e2
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy to Production

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

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Clone latest repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check that the tag exists
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 echo '${{ github.event.inputs.tag }}' | grep -q '^testing-'; 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::testing-`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
- uses: azure/setup-kubectl@v1
- name: Authenticate with kubernetes
run: |
mkdir -p ${HOME}/.kube/certs/cluster
echo ${{ secrets.KUBERNETES_CA }} | base64 -d > ${HOME}/.kube/certs/cluster/k8s-ca.crt
kubectl config set-cluster cluster --certificate-authority=${HOME}/.kube/certs/cluster/k8s-ca.crt --server=https://hatcher.kubernetes.lib.umich.edu
kubectl config set-credentials default --token=${{ secrets.KUBERNETES_TOKEN }}
kubectl config set-context default --cluster=cluster --user=default --namespace=mattlach-github-actions
kubectl config use-context default
- name: Manual Deploy
run: kubectl set image deployment web web=mlibrary/mattlach-phineas-testing-actions:${{ steps.tag_check.outputs.tag }}
42 changes: 42 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy to Staging

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

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Clone latest repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check that the tag exists
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 echo '${{ github.event.inputs.tag }}' | grep -q '^testing-'; 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::testing-`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
- uses: azure/setup-kubectl@v1
- name: Authenticate with kubernetes
run: |
mkdir -p ${HOME}/.kube/certs/cluster
echo ${{ secrets.KUBERNETES_CA }} | base64 -d > ${HOME}/.kube/certs/cluster/k8s-ca.crt
kubectl config set-cluster cluster --certificate-authority=${HOME}/.kube/certs/cluster/k8s-ca.crt --server=https://hatcher.kubernetes.lib.umich.edu
kubectl config set-credentials default --token=${{ secrets.KUBERNETES_TOKEN }}
kubectl config set-context default --cluster=cluster --user=default --namespace=mattlach-github-actions
kubectl config use-context default
- name: Manual Deploy
run: kubectl set image deployment web web=mlibrary/mattlach-phineas-testing-actions:${{ steps.tag_check.outputs.tag }}

0 comments on commit 28f48e2

Please sign in to comment.