* updating workflows * another test for deployment workflow * making the workflows more polished
77 lines
2 KiB
YAML
77 lines
2 KiB
YAML
name: Workflows on Master
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
build_and_deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Python 3.11 for Flake8
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install Flake8
|
|
run: pip install flake8
|
|
|
|
- name: Lint with Flake8
|
|
run: flake8 --ignore=E501,F401,E402,F811,E731,F403,E722 .
|
|
|
|
- name: Set up Python 3.11 for Django
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install Dependencies for Django
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
cp config.example.py config.py
|
|
|
|
- name: Run Tests for Django
|
|
run: |
|
|
python manage.py test
|
|
|
|
- name: Configure SSH for Deployment
|
|
if: success()
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
|
SSH_USER: ${{ secrets.SSH_USER }}
|
|
run: |
|
|
mkdir -p ~/.ssh/
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/github
|
|
chmod 600 ~/.ssh/github
|
|
cat >>~/.ssh/config <<END
|
|
Host target
|
|
HostName $SSH_HOST
|
|
User $SSH_USER
|
|
IdentityFile ~/.ssh/github
|
|
LogLevel ERROR
|
|
StrictHostKeyChecking no
|
|
END
|
|
|
|
- name: Deploy to Production
|
|
if: success() && github.ref == 'refs/heads/master'
|
|
needs: [build_and_deploy]
|
|
run: |
|
|
ssh target "cd tldtest && git pull origin master && docker-compose down && docker-compose up --build -d"
|
|
|
|
- name: Deploy static content to GitHub Pages
|
|
if: success() && github.ref == 'refs/heads/master'
|
|
needs: [build_and_deploy]
|
|
uses: actions/deploy-pages@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|