Hi Prefect Team - I had a question about using Git...
# ask-community
c
Hi Prefect Team - I had a question about using GitHub Actions to deploy from the prefect.yml file. For the Prefect Workspace secret, do we only use the guid from the url for this secret?
1
Copy code
name: Deploy a Prefect flow
on:
  push:
    branches:
      - dev
jobs:
  deploy_flow:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Prefect Auth
        uses: PrefectHQ/actions-prefect-auth@v1
        with:
          prefect-api-key: ${{ secrets.PREFECT_API_KEY }}
          prefect-workspace: ${{ secrets.PREFECT_WORKSPACE }}

      - name: Run Prefect Deploy
        uses: PrefectHQ/actions-prefect-deploy@v3
        with:
          all-deployments: "true"
          requirements-file-paths: ./requirements.txt
Or is the workspace secret simply the name of the workspace? PROD_WORKSPACE: 'prefect-technologies/marvin-bot' DEV_WORKSPACE: 'prefect-technologies/inconspicuous-pond'
k
the prefect auth github action runs
prefect cloud login
and uses the
--workspace
option:
Copy code
--workspace  -w      TEXT  Full handle of workspace, in format '<account_handle>/<workspace_handle>'
c
Thanks Kevin. Do we include the single quotes like the line below? 'sra/dev'
n
hmm i think its actually unnecessary to run
prefect cloud login
, perhaps we should revisit the implementation of that action you should just have to set the env vars and do
prefect cloud workspace set -w acct/handle
https://github.com/zzstoatzz/prefect-monorepo/blob/main/.github/workflows/env-separated-deploy.yml#L5-L53
👀 1
👍 1
k
no need for the quotes
👍 1
c
Thanks guys. I'll pattern off Nate's example.
👍 1
@Nate @Kevin Grismore Is there a way to turn off the schedule in the GitHub actions?
I'd like to make it optional in the workflow dispatcher
n
sorry, do you mean the schedule of the GH action itself, or the deployment schedule?
c
The deployment schedule of the flows
Either in the GH action as an input, or something like that to enable or disable the deployment
n
to clarify, would you like to toggle enable/disable at deployment time? or dynamically set a deployment's schedule at deployment time? or both i suppose you could mean that removing the schedule at deployment time would effectively disable the deployment
c
Copy code
deployments:
    - name: transactions
      description: null
      entrypoint: src/run_sod_loaders.py:Transactions
      work_pool: *ny4_work_pool
      parameters: {}
      schedule:
        cron: 01 7 * * 1-5
        timezone: "America/Chicago"
I'm setting the time in the schedule here, but I'd like to toggle all the deployments on or off
We are deploying all the flows for a repo at the same time. For production, I'd like all the deployments to be scheduled. For development workspace, I'd like it optional.
I'm not sure if that is possible
n
yeah its definitely possible, im trying to think of the easiest way, but the most direct way off the top would be to write a short script like this
then you could invoke that from your github action conditionally if you're pointing at dev
c
Thanks Nate. I'll give this a try.