Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Listening for a specific job or step when waiting #97

Open
selecsosi opened this issue Dec 14, 2024 · 2 comments
Open

Comments

@selecsosi
Copy link
Contributor

selecsosi commented Dec 14, 2024

Hi,

I have a use case for the turnstyle action where I would like it to be "intelligent" enough to listen for a specific job/step in a workflow to complete, rather than relying on the entire run to complete.

I have a proof of concept PR that I'm working on that I will link. The goal here is to take what is currently 2 workflows and combine them into a single workflow with two jobs, the first job is "turnstyled" and performs a git checkout and a gitops commit before pushing back to main. The second part of the job then will trigger a deployment job that might take 1-2 minutes depending on migrations and such.

We would like the run turnstyle, to only consider the first job (or a particular step) as the trigger to gate the action.

Example abbreviated workflow (we also might want to combine the jobs into a single job [thus wanting two new inputs]:

jobs:
  create-deployment-commit:
    runs-on: ubuntu-latest
    steps:
      # Use the turnstyle action to ensure that the checkout and commit steps are run and committed before another job
      # is allowed to run.
      - name: Turnstyle
        uses: softprops/turnstyle@v2
        with:
          # Shortening the poll interval to 10 seconds to ensure that the commit is picked up quickly (default is 60s)
          poll-interval-seconds: 10
          job-to-wait-for: "create-deployment-commit"

      - uses: actions/checkout@v4

      - name: Create GitOps Deployment Commit
        id: create-deployment-commit
        run: >
          ./scripts/deployment/createDeploymentCommit.sh
          -e ${{ inputs.environment }}
          -n ${{ inputs.serviceName }}
          -t ${{ inputs.imageTag }}
          ${{ inputs.verbose && '-v' || '' }}
          ${{ inputs.dryRun && '-d' || '' }}

  sync-argocd-dev:
    runs-on: ubuntu-latest
    steps:
      - name: Setup ArgoCD CLI
        uses: imajeetyadav/argocd-cli@v1
        with:
          version: v2.13.0
      - name: Dev Deployment for Service - ArgoCD Sync
        id: sync-argocd
        if: ${{ !inputs.dryRun }}
        env:
          # Note: ArgoCD deployed applications are prefixed with their namespace, i.e. mono-<service-name>
          ARGOCD_APP_NAME: mono-${{ inputs.serviceName }}
        run: |
          # Refresh the app to ensure the latest changes are detected.
          argocd app get "${ARGOCD_APP_NAME}" --hard-refresh \
            --argocd-context argocd.dev.company.com || exit 1
          # Sync the app to apply the changes
          argocd app sync "${ARGOCD_APP_NAME}" --prune \
            --timeout 300 \
            --argocd-context argocd.dev.company.com
@selecsosi
Copy link
Contributor Author

Linking my POC PR for review: #98

@chenrui333
Copy link
Collaborator

@selecsosi just merged #98 and released in v2.3.0, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants