Skip to content

chore(ci): on demand review app #736

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

abulte
Copy link
Contributor

@abulte abulte commented Apr 15, 2025

Fix ecolabdata/ecospheres#566

Ne déploie par défaut que le site ecospheres. Les autres sites peuvent être déployés via un commentaire sur la PR /deploy {site}.

Cela permet d'alléger la charge sur le serveur qui héberge les preview apps et ne pas faire de déploiement inutile.

Evidemment, cela nécessite une action manuelle vs un déploiement auto de toutes les verticales. Il faut aussi redéployer après le dernier commit le cas échéant.

Disclaimer 🤖 : le workflow review-app-comment-trigger.yml a été largement écrit par une IA.

@github-actions github-actions bot requested a deployment to ecospheres-preview April 15, 2025 09:34 In progress
@github-actions github-actions bot requested a deployment to ecospheres-preview April 15, 2025 09:39 In progress
@github-actions github-actions bot requested a deployment to ecospheres-preview April 15, 2025 10:00 In progress
@abulte
Copy link
Contributor Author

abulte commented Apr 15, 2025

gh workflow run review-app.yml --ref chore/review-app-on-demand -f site=logistique -f pr_number=736

@abulte
Copy link
Contributor Author

abulte commented Apr 15, 2025

/deploy defis

@abulte
Copy link
Contributor Author

abulte commented Apr 15, 2025

Code for comment trigger needs to be on main to be tested :-/

@abulte abulte marked this pull request as ready for review April 15, 2025 16:12
@abulte abulte requested a review from streino April 15, 2025 16:12
required: true
default: 'ecospheres'
type: choice
options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort for maintainability

workflow_dispatch:
inputs:
site:
description: 'Site to deploy (ecospheres, meteo-france, or logistique)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description doesn't match options. I'd remove them to avoid syncing issues.

- name: Set environment variables
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "SITE_ID=${{ github.event.pull_request.head.ref == 'main' && 'ecospheres' || 'ecospheres' }}" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't that always result in 'ecospheres'?

uses: dokku/github-action@master
# ignore errors as the app might already exist on workflow_dispatch
continue-on-error: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be safer to split the two cases (workflow dispatch vs pr deploy) then?

jobs:
process_comment:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/deploy') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/deploy') }}
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/deploy') }}

?

}
});
} catch (error) {
deploymentMessage += `❌ Failed to trigger deployment for ${site}: ${error.message}\n`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
deploymentMessage += `❌ Failed to trigger deployment for ${site}: ${error.message}\n`;
deploymentMessage += `❌ Failed to trigger deployment for '${site}': ${error.message}\n`;

}
}

if (!validSitesFound) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that makes sense. If I /deploy a couple sites at once, I'd want to know about any invalid site, not just when all of them are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, we'd now only deploy "ecospheres" by default, and all other sites would require /deploy. I'm tempted to have a list of defaults sites to deploy instead of just "ecospheres", but maybe not now...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool if new commits triggered redeploy for sites that were previously /deploy'ed. I don't see a simple, obvious way to do it, so probably later.

AVAILABLE_SITES="${{ env.AVAILABLE_SITES }}"

# Extract sites from command
if [[ $COMMENT =~ /deploy\ +([a-zA-Z0-9,-]+) ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comma got me wondering for a while. I'd move it up front and possibly add a comment? Or go with space-delimited site names?

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.

Review app sur demande
2 participants