Skip to content

Update README.md

Update README.md #22

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node

Check failure on line 1 in .github/workflows/build.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/build.yaml

Invalid workflow file

No steps defined in `steps` and no workflow called in `uses` for the following jobs: build
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Build Step
on:
push:
branches: ['master']
pull_request:
branches: [ "master" ]
jobs:
test_django_job:
uses: joelwembo/cloudapp-engine-django/.github/workflows/test-django.yaml@master
build:
runs-on: ubuntu-latest
needs: [test_django_job]
build-and-push-docker-image:
name: Build Docker image and push to repositories
# run only when code is compiling and tests are passing
runs-on: ubuntu-latest
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v3
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.G_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: ./
# Note: tags has to be all lower-case
tags: |
joelwembo/cloudapp-django-web:${{ github.sha }}
ghcr.io/joelwembo/cloudapp-django-web:${{ github.sha }}
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/master' }}
# name: Build Docker Container & Push to DO Registry
# on:
# workflow_call:
# workflow_dispatch:
# push:
# branches: [master]
# pull_request:
# branches: [master]
# jobs:
# test_django_job:
# uses: joelwembo/cloudapp-django/.github/workflows/test-django.yaml@master
# build:
# runs-on: ubuntu-latest
# needs: [test_django_job]
# env:
# CLUSTER_NAME: cloudapp-django-web
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Insall doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DO_API_TOKEN_KEY }}
# - name: Login to DO Container Registry with short-lived creds
# run: doctl registry login --expiry-seconds 1200
# - name: Build container image
# working-directory: ./web
# run: |
# docker build -f Dockerfile \
# -t registry.digitalocean.com/cfe-k8s/django-k8s-web:latest \
# -t registry.digitalocean.com/cfe-k8s/django-k8s-web:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} \
# .
# - name: Push image
# run: |
# docker push registry.digitalocean.com/cfe-k8s/django-k8s-web --all-tags
# - name: K8s cluster kubeconfig file with/ short-lived creds
# run: |
# doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ env.CLUSTER_NAME }}
# - name: Update deployment secrets
# run: |
# cat << EOF >> web/.env.prod
# AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
# DJANGO_SUPERUSER_USERNAME=${{ secrets.DJANGO_SUPERUSER_USERNAME }}
# DJANGO_SUPERUSER_PASSWORD=${{ secrets.DJANGO_SUPERUSER_PASSWORD }}
# DJANGO_SUERPUSER_EMAIL=${{ secrets.DJANGO_SUERPUSER_EMAIL }}
# DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}
# ENV_ALLOWED_HOST=${{ secrets.ENV_ALLOWED_HOST }}
# POSTGRES_DB=${{ secrets.POSTGRES_DB }}
# POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
# POSTGRES_USER=${{ secrets.POSTGRES_USER }}
# POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}
# POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}
# EOF
# kubectl delete secret django-k8s-web-prod-env
# kubectl create secret generic django-k8s-web-prod-env --from-env-file=web/.env.prod
# - name: Update Deployment image
# run: |
# kubectl set image deployment/django-k8s-web-deployment django-k8s-web=registry.digitalocean.com/cfe-k8s/django-k8s-web:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5}
# - name: Wait for rollout to finish
# run: |
# kubectl rollout status deployment/django-k8s-web-deployment
# - name: Post-build Django Commands - Migrate / Collectstatic
# run: |
# export SINGLE_POD_NAME=$(kubectl get pod -l app=django-k8s-web-deployment -o jsonpath="{.items[0].metadata.name}")
# kubectl exec -it $SINGLE_POD_NAME -- bash /app/migrate.sh
# kubectl exec -it $SINGLE_POD_NAME -- bash /app/collectstatic.sh