Skip to content

Modified Pipeline again and updated secrets #29

Modified Pipeline again and updated secrets

Modified Pipeline again and updated secrets #29

name: Fetch Weather 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 Weather Data Collection
run: |
cd weather-data-collect
docker build -t weather-data-collect .
docker run --rm weather-data-collect python -m unittest discover tests
push-to-docker-hub:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- 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 Weather Data Collection to Docker Hub
run: |
cd weather-data-collect
docker build -t weather-data-collect .
docker tag weather-data-collect ${{ secrets.DOCKER_USERNAME }}/weather-data-collect:latest
docker push ${{ secrets.DOCKER_USERNAME }}/weather-data-collect:latest
deploy:
needs: push-to-docker-hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy to Digital Ocean
run: |
# Add deployment steps for Digital Ocean