Bump github actions versions #39
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: Test and Deploy | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USERNAME: postgres | |
POSTGRES_DB: changedetection | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }} | |
- name: Install dependencies | |
run: ./scripts/build.sh | |
- name: Test | |
run: ./scripts/test.sh | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.event_name == 'push' # Skip on pull requests | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install Fly | |
run: | | |
curl -L https://fly.io/install.sh | sh | |
- name: Deploy to Fly | |
run: | | |
export FLYCTL_INSTALL="/home/runner/.fly" | |
export PATH="$FLYCTL_INSTALL/bin:$PATH" | |
fly version | |
fly auth docker | |
bash scripts/deploy.sh | |
env: | |
MACHINE_ID: ${{ secrets.MACHINE_ID }} |