Academy Transcript Rework - Part 1 #314
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
# This is a basic workflow to help you get started with Actions | |
name: CI to Docker Hub | |
# Controls when the action will run. Triggers the workflow on push or pull request events | |
on: | |
push: | |
branches: [master, dev] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- name: Set outputs | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Make Cache Directory | |
run: mkdir bootstrap/cache | |
- name: Set up Node | |
uses: actions/setup-node@v1 | |
- name: Build Docker Image | |
run: docker-compose build --no-cache | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to Docker Hub (Master) | |
if: contains(github.ref, 'master') | |
run: | | |
docker tag vatusa/api vatusa/api:${{ steps.vars.outputs.sha_short }} | |
docker push vatusa/api:${{ steps.vars.outputs.sha_short }} | |
- name: Push to Docker Hub (Dev) | |
if: contains(github.ref, 'dev') | |
run: | | |
docker tag vatusa/api vatusa/api:dev | |
docker push vatusa/api:dev | |
- name: Install kubectl | |
uses: azure/setup-kubectl@v1 | |
with: | |
version: 'v1.21.2' | |
- name: Create kubeconfig | |
run: | | |
mkdir ~/.kube | |
cat << EOF > ~/.kube/config | |
apiVersion: v1 | |
clusters: | |
- cluster: | |
certificate-authority-data: ${{ secrets.KUBECONFIG_CLUSTER_CERT_AUTH_DATA }} | |
server: ${{ secrets.KUBECONFIG_CLUSTER_SERVER }} | |
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | |
contexts: | |
- context: | |
cluster: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | |
user: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin | |
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | |
current-context: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | |
kind: Config | |
preferences: {} | |
users: | |
- name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin | |
user: | |
token: ${{ secrets.KUBECONFIG_CLUSTER_TOKEN }} | |
EOF | |
- name: Deploy to Kubernetes Cluster - Update Deployment | |
if: contains(github.ref, 'master') | |
run: | | |
kubectl set image deployment/api *=vatusa/api:${{ steps.vars.outputs.sha_short }} -n web | |
- name: Deploy to Kubernetes Cluster - Update Cron Job | |
if: contains(github.ref, 'master') | |
run: | | |
kubectl set image cronjob/api-cron *=vatusa/api:${{ steps.vars.outputs.sha_short }} -n web | |
- name: Deploy to Kubernetes Cluster - Update Queue Worker | |
if: contains(github.ref, 'master') | |
run: | | |
kubectl set image deployment/api-queue *=vatusa/api:${{ steps.vars.outputs.sha_short }} -n web |