Update API url #100
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
env: | |
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.1 | |
- name: Install Poetry Dependencies | |
working-directory: ./backend | |
run: | | |
poetry install --no-interaction --no-root | |
- name: Determine Modal Environment Name | |
id: set_env_name | |
run: | | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
echo "::set-output name=env_name::dev" | |
else | |
echo "::set-output name=env_name::pr${{ github.event.pull_request.number }}" | |
fi | |
- name: Create and Set Modal Environment | |
working-directory: ./backend | |
run: | | |
ENV_NAME=${{ steps.set_env_name.outputs.env_name }} | |
set +e # Disable immediate exit on error | |
echo "Creating Modal environment '$ENV_NAME' if it doesn't already exist..." | |
CREATE_OUTPUT=$(poetry run modal environment create $ENV_NAME 2>&1) | |
CREATE_EXIT_CODE=$? | |
set -e # Re-enable immediate exit on error | |
if [ $CREATE_EXIT_CODE -ne 0 ]; then | |
if [[ "$CREATE_OUTPUT" == *"AuthError"* ]]; then | |
echo "Create command output: $CREATE_OUTPUT" | |
echo "Authentication error occurred. Exiting." | |
exit 1 | |
elif [[ "$CREATE_OUTPUT" == *"<Status.ALREADY_EXISTS: 6>"* ]]; then | |
echo "Modal environment '$ENV_NAME' already exists. Setting it as the current environment." | |
else | |
echo "Create command output: $CREATE_OUTPUT" | |
echo "An unknown error occurred. Exiting." | |
exit 1 | |
fi | |
else | |
echo "Modal environment '$ENV_NAME' created successfully." | |
fi | |
echo "Setting Modal environment to '$ENV_NAME'..." | |
poetry run modal config set-environment $ENV_NAME | |
echo "Environment '$ENV_NAME' is now set as the current Modal environment." | |
- name: Deploy Modal stubs as applications | |
working-directory: ./backend | |
run: | | |
poetry run modal deploy src.common |