Skip to content

Commit

Permalink
chore: simplify actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kjappelbaum committed Aug 11, 2024
1 parent f0d2bc6 commit 7e709f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/test.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: Test, Deploy, and Verify
name: Deploy and Verify

on:
pull_request:
types: [opened, reopened, synchronize]
pull_request_target:
types: [labeled, synchronize]
push:
branches:
- main
- "**"
workflow_dispatch:

jobs:
check_and_run:
deploy_and_test:
runs-on: ubuntu-latest

steps:
Expand All @@ -36,22 +32,12 @@ jobs:
- name: Check for 'safe to deploy' label
id: check_label
run: |
echo "Event name: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
if [[ ${{ contains(github.event.pull_request.labels.*.name, 'safe to deploy') }} == 'true' ]]; then
echo "safe_to_deploy=true" >> $GITHUB_OUTPUT
else
echo "safe_to_deploy=false" >> $GITHUB_OUTPUT
fi
echo "safe_to_deploy=${{ contains(github.event.pull_request.labels.*.name, 'safe to deploy') }}" >> $GITHUB_OUTPUT
else
echo "safe_to_deploy=true" >> $GITHUB_OUTPUT
fi
- name: Run pre-deployment tests
if: steps.check_label.outputs.safe_to_deploy == 'true'
run: poetry run pytest tests --ignore=tests/test_modal.py

- name: Check for Modal secrets
id: check_secrets
if: steps.check_label.outputs.safe_to_deploy == 'true'
Expand All @@ -63,18 +49,14 @@ jobs:
fi
- name: Deploy to dev
if: |
steps.check_label.outputs.safe_to_deploy == 'true' &&
steps.check_secrets.outputs.modal_secrets_set == 'true'
if: steps.check_label.outputs.safe_to_deploy == 'true' && steps.check_secrets.outputs.modal_secrets_set == 'true'
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
run: poetry run chemenv deploy

- name: Run post-deployment tests
if: |
steps.check_label.outputs.safe_to_deploy == 'true' &&
steps.check_secrets.outputs.modal_secrets_set == 'true'
if: steps.check_label.outputs.safe_to_deploy == 'true' && steps.check_secrets.outputs.modal_secrets_set == 'true'
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Actions

on:
pull_request:
types: [opened, reopened, synchronize, labeled]

jobs:
check_label_and_tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Poetry
run: pip install poetry

- name: Install dependencies
run: poetry install

- name: Check for 'safe to deploy' label
id: check_label
run: |
echo "Event name: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
if [[ ${{ contains(github.event.pull_request.labels.*.name, 'safe to deploy') }} == 'true' ]]; then
echo "safe_to_deploy=true" >> $GITHUB_OUTPUT
else
echo "safe_to_deploy=false" >> $GITHUB_OUTPUT
fi
- name: Run pre-deployment tests
if: steps.check_label.outputs.safe_to_deploy == 'true'
run: poetry run pytest tests --ignore=tests/test_modal.py

0 comments on commit 7e709f3

Please sign in to comment.