Skip to content

Deploy

Deploy #4037

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- master
paths-ignore:
- '**.md'
schedule:
# Every 8 hours = 3 times a day
- cron: '0 */8 * * *'
jobs:
deploy:
# Do not run the scheduled workflow on forks
if: github.event_name != 'schedule' || github.repository_owner == 'Cockatrice'
name: Check for new spoiler
runs-on: ubuntu-latest
env:
DEPLOY: ${{github.ref == 'refs/heads/master'}}
OUTPUT_PATH: out
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Checkout output branch
# Run only when triggered from master
if: env.DEPLOY == 'true'
uses: actions/checkout@v4
with:
ref: files
fetch-depth: 0
path: ${{env.OUTPUT_PATH}}
- name: Install requirements using pip
shell: bash
env:
CFLAGS: '-O0'
run: |
python3 -m pip install --upgrade pip setuptools
python3 -m pip install --requirement requirements.txt
- name: Run script
id: run
shell: bash
run: python3 -m magic_spoiler
- name: Upload artifacts
# Run only when triggered from a PR
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: spoiler-output
path: ${{github.workspace}}/${{env.OUTPUT_PATH}}
if-no-files-found: error
- name: Deploy changes
# Run only when triggered from master and changes are available
if: env.DEPLOY == 'true' && steps.run.outputs.deploy == 'true'
shell: bash
working-directory: ${{env.OUTPUT_PATH}}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add "*.xml" SpoilerSeasonEnabled
git commit -m "Deploy: $GITHUB_SHA"
git push
deploy_commit=`git rev-parse HEAD`
echo "::notice title=New data uploaded::See deployment: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$deploy_commit"