Feature/workflow #9
Workflow file for this run
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
name: Solar System Workflow | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- 'feature/*' | ||
env: | ||
MONGO_URI: mongodb+srv://supercluster.d83jj.mongodb.net/superData | ||
MONGO_USERNAME: superuser | ||
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }} | ||
jobs: | ||
unit-testing: | ||
name: Unit Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Setup NodeJS Version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Unit Testing | ||
run: npm test | ||
- name: Archive Test Result | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Mocha-Test-Result | ||
path: test-results.xml | ||
docker: | ||
permissions: #added | ||
packages: write #added | ||
runs-on: ubuntu-latest | ||
needs: | ||
#- code-coverage | ||
- unit-testing | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/[email protected] | ||
with: | ||
#registry: ghcr.io | ||
registry: docker.io | ||
#username: '${{ github.repository_owner }}' | ||
username: 'seyiogunniran' | ||
# password: '${{ secrets.GITHUB_TOKEN }}' | ||
password: '${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}' | ||
- uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: 'docker.io/seyiogunniran/solar-system:${{ github.sha }}' | ||
#tags: 'ghcr.io/${{ github.repository_owner }}/solar-system:${{ github.sha }}' | ||
dev-deploy: | ||
needs: docker | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: development | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Install kubectl Cli | ||
uses: azure/setup-kubectl@v3 | ||
with: | ||
version: v1.26.0 | ||
- name: Set kubconfig file | ||
uses: azure/k8s-set-context@v3 | ||
with: | ||
method: kubeconfig | ||
kubeconfig: '${{ secrets.KUBECONFIG }}' | ||
- name: Fetch kubernetes cluster details | ||
run: | | ||
kubectl version --short -o yaml | ||
echo -------------------------- | ||
kubectl get nodes | ||
- name: Save AWS Ingress Controller IP as a GITHUB Env variable | ||
run: | | ||
kubectl get ingress -n game-2048 | ||
- name: Replace Token in Manifest files | ||
uses: cschleiden/replace-tokens@v1 | ||
with: | ||
tokenPrefix: '_{_' | ||
tokenSuffix: '_}_' | ||
files: '["kubernetes/development/*.yaml"]' | ||
env: | ||
NAMESPACE: ${{ vars.NAMESPACE }} | ||
REPLICAS: ${{ vars.REPLICAS }} | ||
IMAGE: docker.io/seyiogunniran/solar-systems:${{ github.sha }} | ||
- name: Check files list | ||
run: cat kubernetes/development/*.yaml | ||
- name: Create MongoDB Seceret | ||
run: | | ||
kubectl -n ${{ vars.NAMESPACE }} create secret generic mongo-db-creds | ||
---literal=MONGO_URI=${{ env.MONGO_URI }} \ | ||
---literal=MONGO_USERNAME=${{ env.MONGO_USERNAME }} \ | ||
---literal=MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} \ | ||
---save-config \ | ||
---dry-run=client \ | ||
-o yaml | kubectl apply -f - | ||
- name: Deploy kubernetes | ||
run: | | ||
kubectl apply -f kubernetes/development | ||