generated from nyu-software-engineering/final-project
-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (51 loc) · 1.83 KB
/
weatherDataCollect.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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:
- 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 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:
- name: Checkout Code
uses: actions/checkout@v2
- name: Deploy to DigitalOcean
env:
DIGITALOCEAN_CLI_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
run: |
sudo snap install doctl
doctl auth init --access-token ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
doctl apps update aced4801-b44c-42ac-a993-b2fc1790e609 --spec .do/weather-data-collect.yaml