-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deploy to staging and production
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |
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
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 }} |