Updated Workflows (#43)

This commit is contained in:
Arnold Dechamps 2024-05-11 02:29:01 +02:00 committed by GitHub
parent a9be693e56
commit f5e9b5e4ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 95 additions and 141 deletions

View file

@ -1,36 +0,0 @@
name: Deploy
on:
push:
branches:
- master
concurrency:
group: master
cancel-in-progress: true
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Configure SSH
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: Run Deploy
run: |
ssh target "cd tldtest && git pull origin master && docker-compose down && docker-compose up --build -d"

48
.github/workflows/deployment.yml vendored Normal file
View file

@ -0,0 +1,48 @@
name: Deploying
on:
workflow_run:
workflows: ["Deploy", "Deploy static content to Pages"]
branches:
- master
types:
- completed
jobs:
deploy_after_master_push:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Deploy via SSH
if: github.event.workflow_run.name == 'Deploy'
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
ssh target "cd tldtest && git pull origin master && docker-compose down && docker-compose up --build -d"
- name: Deploy static content to GitHub Pages
if: github.event.workflow_run.name == 'Deploy static content to Pages'
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_commit.sha }}
- name: Deploy static content to Pages
if: github.event.workflow_run.name == 'Deploy static content to Pages'
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,31 +0,0 @@
name: Django CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
cp config.example.py config.py
- name: Run Tests
run: |
python manage.py test

View file

@ -1,31 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Flake 8
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install flake
run: |
pip install flake8
- name: Lint with flake8
run: |
flake8 --ignore=E501,F401,E402,F811,E731,F403,E722 .

47
.github/workflows/pull-request.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: Django test and Flake 8
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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 .
django:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} for Django
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- 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

View file

@ -1,43 +0,0 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './staticfiles'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4