Skip to content

Merge pull request #260 from ItsCalebJones/remove_sorl_thumbnail #80

Merge pull request #260 from ItsCalebJones/remove_sorl_thumbnail

Merge pull request #260 from ItsCalebJones/remove_sorl_thumbnail #80

Workflow file for this run

name: Build SLN Release
on:
workflow_dispatch:
push:
branches:
- "master"
tags:
- '**'
env:
IMAGE_NAME: space-launch-now-base
REGISTRY_NAME: registry.digitalocean.com/spacelaunchnow-registry/
POETRY_HTTP_BASIC_TSD_USERNAME: ${{ secrets.PRIVATE_USERNAME }}
POETRY_HTTP_BASIC_TSD_PASSWORD: ${{ secrets.PRIVATE_PASSWORD }}
RELEASE_NAME: sln-staging-app
WEB_DEPLOYMENT: sln-staging-app-django-web
DEPLOYMENT_NAMESPACE: sln-dev
VALUES: k8s/helm/values-staging.yaml
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run Python Tests
uses: ./.github/actions/python-test
doctl-registry:
# Ensure test job passes before pushing image.
needs: test
name: Deploy to Container Registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Login to container registry
run: doctl registry login --expiry-seconds 600
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: registry.digitalocean.com/spacelaunchnow-registry/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
build-args: |
PRIVATE_USERNAME=${{ secrets.PRIVATE_USERNAME }}
PRIVATE_PASSWORD=${{ secrets.PRIVATE_PASSWORD }}
push: true
tags: ${{ steps.meta.outputs.tags }}, ${{env.REGISTRY_NAME}}${{ env.IMAGE_NAME }}:staging
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: doctl-registry
name: Deploy to Kubernetes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.24.0'
- name: Install helm
uses: azure/setup-helm@v3
with:
version: 'v3.8.1'
- name: Create kubeconfig
run: |
mkdir ${HOME}/.kube
echo ${{ secrets.KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config
chmod go-r ${HOME}/.kube/config
- name: Deploy to K8s
run: |
kubectl config use-context do-nyc1-k8s-spacelaunchnow-prod
export DEPLOYS=$(helm ls --all-namespaces | grep $RELEASE_NAME | wc -l)
if [ $DEPLOYS -eq 0 ];
then
helm install $RELEASE_NAME k8s/helm/ --namespace=$DEPLOYMENT_NAMESPACE --values $VALUES
else
helm upgrade $RELEASE_NAME k8s/helm/ --namespace=$DEPLOYMENT_NAMESPACE --values $VALUES
kubectl rollout restart deploy $WEB_DEPLOYMENT --namespace=$DEPLOYMENT_NAMESPACE
fi
release:
name: Build Release
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.12.4'
- name: Python Semantic Release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}