Show the region latency even when its not available #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Koyeb Preview Environment | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [opened, reopened, synchronize, closed] | |
jobs: | |
environment: | |
name: Environment name | |
runs-on: ubuntu-latest | |
outputs: | |
name: ${{ steps.environment.outputs.name }} | |
app-name: ${{ steps.environment.outputs.name }}-console | |
steps: | |
- name: Compute environment name | |
id: environment | |
run: | | |
branch=${{ github.head_ref }} | |
environment=$(echo "${branch##*/}" | cut -c 1-14) | |
environment="${environment%-}" | |
environment="${environment#-}" | |
echo "name=$environment" >> $GITHUB_OUTPUT | |
control-panel: | |
name: Deploy Control Panel | |
runs-on: ubuntu-latest | |
needs: environment | |
if: github.event.action != 'closed' | |
concurrency: | |
group: ${{ github.head_ref }}-control-panel | |
cancel-in-progress: true | |
steps: | |
- name: Install Koyeb CLI | |
uses: koyeb-community/install-koyeb-cli@v2 | |
with: | |
api_token: ${{ secrets.KOYEB_TOKEN }} | |
- name: Environment variables | |
id: environment-variables | |
shell: bash | |
run: | | |
variables=( | |
ENVIRONMENT=preview | |
APP_VERSION=${{ github.event.pull_request.head.sha || github.sha }} | |
API_URL=https://staging.koyeb.com | |
PAGE_CONTEXT_BASE_URL=@control-panel-staging-page-context-base-url | |
RECAPTCHA_CLIENT_KEY=@control-panel-staging-recaptcha-client-key | |
SEGMENT_WRITE_KEY=@control-panel-staging-segment-write-key | |
POSTHOG_KEY=@control-panel-staging-posthog-key | |
STRIPE_PUBLIC_KEY=@control-panel-staging-stripe-public-key | |
MAPBOX_TOKEN=@control-panel-staging-mapbox-token | |
SENTRY_AUTH_TOKEN=@control-panel-staging-sentry-auth-token | |
) | |
IFS=, ; echo "env=${variables[*]}" >> $GITHUB_OUTPUT | |
- name: Deploy | |
uses: koyeb/action-git-deploy@v1 | |
with: | |
app-name: ${{ needs.environment.outputs.app-name }} | |
service-name: control-panel | |
git-branch: ${{ github.head_ref }} | |
git-builder: docker | |
service-instance-type: nano | |
service-regions: fra | |
service-ports: 3000:http | |
service-routes: /:3000 | |
service-env: ${{ steps.environment-variables.outputs.env }} | |
- name: Change autoassigned domain | |
run: koyeb apps update $APP_NAME --domain $DOMAIN | |
env: | |
APP_NAME: ${{ needs.environment.outputs.app-name }} | |
DOMAIN: ${{ needs.environment.outputs.app-name }}-koyeb | |
storybook: | |
name: Deploy Storybook | |
runs-on: ubuntu-latest | |
needs: environment | |
if: github.event.action != 'closed' | |
concurrency: | |
group: ${{ github.head_ref }}-design-system | |
cancel-in-progress: true | |
steps: | |
- name: Install Koyeb CLI | |
uses: koyeb-community/install-koyeb-cli@v2 | |
with: | |
api_token: ${{ secrets.KOYEB_TOKEN }} | |
- name: Deploy Storybook | |
uses: koyeb/action-git-deploy@v1 | |
with: | |
app-name: ${{ needs.environment.outputs.app-name }} | |
service-name: storybook | |
git-branch: ${{ github.head_ref }} | |
service-instance-type: nano | |
service-regions: fra | |
service-ports: 8000:http | |
service-routes: /storybook:8000 | |
git-build-command: pnpm run build-storybook --quiet | |
git-run-command: pnpx http-server storybook-static | |
github-comment: | |
name: Github Comment | |
runs-on: ubuntu-latest | |
needs: [environment, control-panel, storybook] | |
if: github.event.action != 'closed' | |
steps: | |
- name: Install Koyeb CLI | |
uses: koyeb-community/install-koyeb-cli@v2 | |
with: | |
api_token: ${{ secrets.KOYEB_TOKEN }} | |
- name: Seed Koyeb info | |
id: info | |
run: | | |
info=$(koyeb app describe ${{ needs.environment.outputs.app-name }} -o json) | |
service=$(echo $info | jq -r '.services[] | select(.name == "control-panel")') | |
echo "app_id=$(echo $info | jq -r '.id' | sed '/null/d')" >> $GITHUB_OUTPUT | |
echo "app_url=$(echo $info | jq -r '.domains[0].name' | sed '/null/d')" >> $GITHUB_OUTPUT | |
echo "deployment_id=$(echo $service | jq -r '.latest_deployment_id' | sed '/null/d')" >> $GITHUB_OUTPUT | |
echo "service_id=$(echo $service | jq -r '.id' | sed '/null/d')" >> $GITHUB_OUTPUT | |
- name: Find Comment | |
uses: peter-evans/find-comment@v3 | |
if: success() && github.event.number | |
id: fc | |
with: | |
issue-number: ${{ github.event.number }} | |
body-includes: This pull request initialized a new Koyeb App and Service to deploy your application. | |
- name: Upsert Comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
edit-mode: replace | |
reactions: rocket | |
body: | | |
This pull request initialized a new Koyeb App and Service to deploy your application. | |
To tack the status of your deployment, click below. | |
🔍 Track the latest deployment: https://app.koyeb.com/apps/${{ steps.info.outputs.app_id }}/services/${{ steps.info.outputs.service_id }}/deployments/${{ steps.info.outputs.deployment_id }} | |
✅ Preview: https://${{ steps.info.outputs.app_url }} | |
📖 Design System: https://${{ steps.info.outputs.app_url }}/design-system/ | |
📖 Storybook: https://${{ steps.info.outputs.app_url }}/storybook/ | |
cleanup: | |
name: Delete Koyeb Application | |
runs-on: ubuntu-latest | |
needs: environment | |
if: github.event.action == 'closed' | |
steps: | |
- name: Install Koyeb CLI | |
uses: koyeb-community/install-koyeb-cli@v2 | |
with: | |
api_token: ${{ secrets.KOYEB_TOKEN }} | |
- name: Delete Koyeb application | |
uses: koyeb/action-git-deploy/cleanup@v1 | |
with: | |
app-name: ${{ needs.environment.outputs.app-name }} |