Skip to main content

How do I configure GitHub Workflow for Deploying to a Long-Lived Environment on Merge?

External Action

The configuration described here takes place outside of Wayfinder.


Prerequisites


Why do I need this configuration?

In this section you're configuring the .github/workflows/main.yaml file so that it deploys your component to your long-lived PROD environment.


Update .github/workflows/main.yaml

Update the .github/workflows/main.yaml file as per the example.

In the section below you are assigning the values for the workspace access token's variables that you've created earlier.

        env:
WAYFINDER_SERVER: ${{ vars.WAYFINDER_SERVER }}
WAYFINDER_WORKSPACE: ${{ vars.WAYFINDER_WORKSPACE }}
WAYFINDER_TOKEN: ${{ secrets.WAYFINDER_TOKEN }}

In the section below you are deploying your component to your long-lived PROD environment.

        run: |
wf deploy component ${{ vars.APP_NAME }} ${{ vars.LIVE_ENV_NAME }} --component ${{ vars.APP_COMPONENT_NAME }} --image ${{ needs.build.outputs.tags }} --wait-for-ready 3m


Following below is the complete example that deploys to your long-lived PROD environment.


name: main-publish

on:
push:
branches: [main]

permissions:
contents: read # Required for actions/checkout
checks: write # Set status of checks
issues: write # Comment the PR as we go
statuses: write # Set commit statuses as tests pass or fail
pull-requests: write # Get/comment the PR itself
packages: write # Write to ghcr.io

jobs:
build:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Login to docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/wfexample
tags: |
type=ref,event=branch,suffix=-{{sha}}
type=ref,event=pr,suffix=-{{sha}}
- name: Build and Push to GitHub Packages
id: build-push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy-live:
needs:
- build
runs-on: ubuntu-latest
container:
image: quay.io/appvia-wayfinder/wftoolbox:latest
steps:
- name: Deploy to app environment
id: deploy
env:
WAYFINDER_SERVER: ${{ vars.WAYFINDER_SERVER }}
WAYFINDER_WORKSPACE: ${{ vars.WAYFINDER_WORKSPACE }}
WAYFINDER_TOKEN: ${{ secrets.WAYFINDER_TOKEN }}
run: |
wf deploy component ${{ vars.APP_NAME }} ${{ vars.LIVE_ENV_NAME }} --component ${{ vars.APP_COMPONENT_NAME }} --image ${{ needs.build.outputs.tags }} --wait-for-ready 3m