Skip to content

Add files via upload #690

Add files via upload

Add files via upload #690

name: Build and deploy
on: push
env:
REDDIT_USERNAME: AnimeMod
REDDIT_PASSWORD: ${{ secrets.ANIMEMOD_PASSWORD }}
REDDIT_TOTP_SECRET: ${{ secrets.ANIMEMOD_TOTP_SECRET }}
REDDIT_CLIENT_ID: ${{ secrets.STYLESHEET_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.STYLESHEET_CLIENT_SECRET }}
REDDIT_REDIRECT_URI: ${{ secrets.STYLESHEET_REDIRECT_URI }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pip requirements
run: pip install -r utils/requirements.txt
- name: Install Sass
run: npm install --no-save sass
- name: Build and some other testing stuff
run: |
python utils/validate.py
- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: stylesheet_build
if-no-files-found: ignore
path: |
stylesheet.css
images
subreddit_data.yml
css_validation_result.html
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pip requirements
run: |
pip install -r utils/requirements.txt
- name: Install Sass
run: npm install --no-save sass
- name: Detect target environment
id: target
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
echo Targeting /r/anime
echo "environment=production" >> $GITHUB_OUTPUT
echo "subreddit=anime" >> $GITHUB_OUTPUT
else
echo Targeting /r/animestaging
echo "environment=staging" >> $GITHUB_OUTPUT
echo "subreddit=animestaging" >> $GITHUB_OUTPUT
fi
- name: Create GitHub deployment
uses: chrnorm/[email protected]
id: deployment
with:
token: ${{ github.token }}
target_url: https://old.reddit.com/r/${{ steps.target.outputs.subreddit }}
environment: ${{ steps.target.outputs.environment }}
- name: Deploy
env:
REDDIT_SUBREDDIT: ${{ steps.target.outputs.subreddit }}
run: |
python utils/build.py -r "${{ github.event.compare }}"
python utils/update.py
- name: Update deployment status (success)
if: success()
uses: chrnorm/[email protected]
with:
token: ${{ github.token }}
state: success
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/[email protected]
with:
token: ${{ github.token }}
state: failure
deployment_id: ${{ steps.deployment.outputs.deployment_id }}