removed redundant folder #70
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: Web App CI/CD | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Build and Test Web Application | |
run: | | |
cd web-app | |
docker build -t web-app . | |
docker run --rm web-app python -m unittest discover tests | |
push-to-docker-hub: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Check if secrets are empty | |
run: | | |
if [ -z "${{ secrets.DOCKER_USERNAME }}" ] || [ -z "${{ secrets.DOCKER_PASSWORD }}" ]; then | |
echo "One of the secrets is empty!" | |
else | |
echo "Secrets are not empty." | |
fi | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Push Web App to Docker Hub | |
run: | | |
cd web-app | |
docker build -t web-app . | |
docker tag web-app ${{ secrets.DOCKER_USERNAME }}/web-app:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/web-app:latest | |
deploy: | |
needs: push-to-docker-hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Deploy to DigitalOcean | |
run: | | |
sudo snap install doctl | |
doctl auth init --access-token ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
doctl apps list --format ID,Created | |
#doctl apps update 732db8dc-5866-4235-8935-679232b31cb2 --spec web-app/app.yaml |