Skip to content

feat: update github actions #81

feat: update github actions

feat: update github actions #81

name: lektor-deployment
env:
PYTHON_VERSION: '3.10'
NODE_VERSION: '14.2.0'
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: packages-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi
# -----------------------------
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Yarn
run: npm install -g yarn
- name: Load cached Yarn
id: cached-yarn-dependencies
uses: actions/cache@v3
with:
path: ./webpack/node_modules
key: packages-${{ runner.os }}-${{ hashFiles('**/webpack/yarn.lock') }}
- name: Install dependencies
if: steps.cached-yarn-dependencies.outputs.cache-hit != 'true'
run: cd webpack && yarn
# -----------------------------
- name: Deploy Finished
run: echo "Deploy finished at $(date +'%Y-%m-%dT%H:%M:%S')!"
deploy-dev:
name: Deploy to Development
if: github.event_name == 'pull_request'
needs: [build]
runs-on: ubuntu-latest
environment:
name: Development
steps:
- name: Deploy Finished
run: echo "Deploy finished at $(date +'%Y-%m-%dT%H:%M:%S')!"
deploy-staging:
name: Deploy to Staging
if: github.event.ref == 'refs/heads/main'
needs: [build]
runs-on: ubuntu-latest
environment:
name: Staging
url: 'https://dev.scipy.lat/'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: packages-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi
# -----------------------------
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Yarn
run: npm install -g yarn
- name: Load cached Yarn
id: cached-yarn-dependencies
uses: actions/cache@v3
with:
path: ./webpack/node_modules
key: packages-${{ runner.os }}-${{ hashFiles('**/webpack/yarn.lock') }}
- name: Install dependencies
if: steps.cached-yarn-dependencies.outputs.cache-hit != 'true'
run: cd webpack && yarn
# -----------------------------
- name: Deploy Finished
env:
LEKTOR_DEPLOY_USERNAME: ${{ secrets.LEKTOR_DEPLOY_USERNAME }}
LEKTOR_DEPLOY_PASSWORD: ${{ secrets.LEKTOR_DEPLOY_PASSWORD }}
URL_SITE: ${{ secrets.URL_SITE }}
GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}
run: |
envsubst < "lektorproject.template" > "scipy-latin-america-2021.lektorproject"
envsubst < "google-analytics.template" > "configs/google-analytics.ini"
poetry run lektor build -f webpack
poetry run lektor deploy staging
echo "Deploy finished at $(date +'%Y-%m-%dT%H:%M:%S')!"
deploy-production:
name: Deploy to Production
needs: [deploy-staging]
runs-on: ubuntu-latest
environment:
name: Production
url: 'https://conf.scipy.lat/'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: packages-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi
# -----------------------------
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Yarn
run: npm install -g yarn
- name: Load cached Yarn
id: cached-yarn-dependencies
uses: actions/cache@v3
with:
path: ./webpack/node_modules
key: packages-${{ runner.os }}-${{ hashFiles('**/webpack/yarn.lock') }}
- name: Install dependencies
if: steps.cached-yarn-dependencies.outputs.cache-hit != 'true'
run: cd webpack && yarn
# -----------------------------
- name: Deploy Finished
env:
LEKTOR_DEPLOY_USERNAME: ${{ secrets.LEKTOR_DEPLOY_USERNAME }}
LEKTOR_DEPLOY_PASSWORD: ${{ secrets.LEKTOR_DEPLOY_PASSWORD }}
run: |
poetry run lektor build -f webpack
poetry run lektor deploy production
echo "Deploy finished at $(date +'%Y-%m-%dT%H:%M:%S')!"