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

Allow calling even if deployment exists #3

Open
kzlar opened this issue May 19, 2024 · 3 comments
Open

Allow calling even if deployment exists #3

kzlar opened this issue May 19, 2024 · 3 comments

Comments

@kzlar
Copy link
Contributor

kzlar commented May 19, 2024

Hi @Faolain !

First of all, really appreciate your effort on this! It just works and saved me hours of figuring this out myself!
I wanted to ask whether it would be possible to make this action work without if: github.event.action == 'opened'. I'm using the railway deployment in conjunction with neondb branch create (neondatabase/create-branch-action@v5) and neondb's action is called every time and silently exists if the branch already exists. I think that would be a great addition to this action as well.

Thank you for your consideration!

@Faolain
Copy link
Owner

Faolain commented Aug 29, 2024

Hey @kzlar apologies for the delay here! Appreciate the kind words. So I have the same setup with neondb but not exactly sure how calling even if deployment exists "fixes" this or what it addresses

Currently my setup using this action with neondb is as follows:

jobs:
  deploy:
    runs-on: ubuntu-latest
    if: github.event_name != 'pull_request' || github.event.action != 'closed'
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }} # Check out the source branch of the PR

      - name: Create a Neon Branch 🚀
        uses: neondatabase/create-branch-action@v4
        with:
          project_id: ${{ secrets.NEON_PROJECT_ID }}
          parent: staging
          branch_name: pr-${{ github.event.pull_request.number }}
          api_key: ${{ secrets.NEON_API_KEY }}
        id: create_branch

      - name: Create PR environment on Railway
        id: railway_deploy
        if: github.event.action == 'opened' || github.event.action == 'reopened'
        uses: Faolain/[email protected]
        with:
          RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
          PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }}
          SRC_ENVIRONMENT_NAME: staging
          DEST_ENV_NAME: pr-${{ github.event.pull_request.number }}
          PROVIDER: python
          ENV_VARS: '{"LOG_DD_AGENT_HOST": "", "APP_ENVIRONMENT": "docker", "DATABASE_URL": "postgresql+asyncpg://${{ secrets.NEON_USERNAME }}:${{ secrets.NEON_DB_PASSWORD }}@${{ steps.create_branch.outputs.host}}/neondb", "REDIS_URL": "redis://default:${{ steps.create_redis.outputs.redis_password }}@${{ steps.create_redis.outputs.redis_endpoint }}:${{ steps.create_redis.outputs.redis_port }}"}'
          branch_name: ${{ github.head_ref }}

As this action only deals with railway and doesn't affect neon (or any database for that matter).

@Faolain
Copy link
Owner

Faolain commented Sep 28, 2024

Does this help @kzlar ? It doesn't necessarily need to use "opened" just had that as an example on the README. The railway action can be different than the condition for the db.

@kzlar
Copy link
Contributor Author

kzlar commented Sep 28, 2024

@Faolain Hey - I replied on the PR #5 (comment) let me know if it makes things clearer.

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