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

👀 More featured and bugfixed action #61

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

JargeZ
Copy link

@JargeZ JargeZ commented Jul 20, 2024

Originally I created a pull request for one extension for my needs

However, since then I have added a lot of new things, so feel free to look, try, write comments and your feedback.


I use fly to preview applications, but it often happens that two repositories are linked to each other.

For example, we have new functionality that affects the backend and frontend of the repository.
To do this, I want to have a copy of the front-end preview-app that uses the corresponding base url of the back-end preview-app copy

I achieved this using a cross repository of reused workflow

Frontend's fly-rewiew.yaml

name: Deploy Review App
on:
  pull_request:
    types: [ opened, reopened, synchronize, closed ]
  workflow_call:
    inputs:
      branch_name:
        type: string
        description: 'Branch name'
        required: false
        default: ${{ github.event.pull_request.head.ref }}

jobs:
  review_app:
    runs-on: ubuntu-latest
    outputs:
      url: ${{ steps.deploy.outputs.url }}
    concurrency:
      group: pr-${{ github.event.number }}
    environment:
      name: review
      url: ${{ steps.deploy.outputs.url }}
    steps:
      - name: Get code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch_name || github.event.pull_request.head.ref }}
      - name: Deploy PR app to Fly.io
        id: deploy
        uses: JargeZ/fly-pr-review-apps@unsafe-name
        with:
          name: my-frontend-${{ inputs.branch_name || github.event.pull_request.head.ref }}
          allow_unsafe_name: true
          build_args: NEXT_PUBLIC_BACKEND_BASE_URL=https://my-backend-${{ inputs.branch_name || github.event.pull_request.head.ref }}.fly.dev

Backend's fly-review.yaml

name: Deploy Review App
on:
  pull_request:
    types: [ opened, reopened, synchronize, closed ]

jobs:
  # Deploy corresponding frontend for the PR only if name contains '@fe'.
  frontend:
    if: ${{ contains(github.event.pull_request.title, '@fe') }}
    uses: JargeZ/my-frontend/.github/workflows/fly-review.yml@main
    with:
      branch_name: ${{ github.event.pull_request.head.ref }}
    secrets: inherit

  review_app:
    runs-on: ubuntu-latest
    outputs:
      url: ${{ steps.deploy.outputs.url }}
    concurrency:
      group: pr-${{ github.event.number }}
    environment:
      name: review
      url: ${{ steps.deploy.outputs.url }}/
    steps:
      - name: Get code
        uses: actions/checkout@v4
      - name: Deploy PR app to Fly.io
        id: deploy
        uses: JargeZ/fly-pr-review-apps@unsafe-name
        with:
          name: my-backend-${{ github.event.pull_request.head.ref }}
          postgres: my-backend-dev-db
          config: fly-preview.toml
          allow_unsafe_name: true

Thus, we use the branch name to synchronize the backend and frontend.

To do this, the name of the branch must be the same in both repositories; usually this will be linked to a card from the task tracker.
You can also pre-process the branch name to, for example, extract numbers and use only the Jira ticket number.

I also think you can make an approach to build args as it was in pull request #50 and merge it before

@JargeZ JargeZ marked this pull request as draft August 16, 2024 09:39
@JargeZ JargeZ force-pushed the unsafe-name branch 7 times, most recently from 6fa0a1a to e1cd01e Compare August 21, 2024 06:34
@JargeZ JargeZ force-pushed the unsafe-name branch 5 times, most recently from 6e91b07 to f47aaa9 Compare September 4, 2024 03:08
@JargeZ JargeZ force-pushed the unsafe-name branch 3 times, most recently from 99de34c to c377247 Compare September 10, 2024 07:43
@JargeZ JargeZ changed the title Pass build-args and custom app name to achieve in-sync multi-repository preview deploy More featured and bugfixed action Sep 10, 2024
@JargeZ JargeZ changed the title More featured and bugfixed action 👀 More featured and bugfixed action Sep 10, 2024
@JargeZ JargeZ force-pushed the unsafe-name branch 3 times, most recently from bf750d8 to d6ae3ae Compare October 25, 2024 00:43
This reverts commit 2045310.
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

Successfully merging this pull request may close these issues.

1 participant