Skip to content

Flowforge - build and deploy #3389

Flowforge - build and deploy

Flowforge - build and deploy #3389

name: Flowforge - build and deploy
on:
workflow_dispatch:
inputs:
flowforge_release_name:
description: 'flowforge package version'
required: false
default: 'nightly'
flowforge_ref:
description: 'flowforge package ref'
required: false
push:
branches:
- main
paths:
- 'flowforge-container/**'
- '.github/workflows/flowforge-container.yml'
pull_request:
branches:
- main
paths:
- 'flowforge-container/**'
- '.github/workflows/flowforge-container.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
name: Build single-architecture container images
uses: flowfuse/github-actions-workflows/.github/workflows/build_container_image.yml@v0.52.0
with:
image_name: 'forge-k8s'
package_dependencies: |
@flowfuse/flowfuse=nightly
@flowfuse/driver-kubernetes=nightly
build_context: 'flowforge-container'
build_platform: "linux/amd64"
npm_registry_url: ${{ vars.PUBLIC_NPM_REGISTRY_URL }}
scan_image: true
secrets:
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
upload-stage-image:
if: github.ref_name == 'main'
name: Upload image to staging registry
needs: build
uses: flowfuse/github-actions-workflows/.github/workflows/deploy_container_image.yml@v0.52.0
with:
environment: stage
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
deploy: false
image: ${{ needs.build.outputs.image }}
aws_ecr_iam_role_name: ECR_push_pull_images
secrets:
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}
upload-production-image:
if: github.ref_name == 'main'
name: Upload image to production registry
needs: build
uses: flowfuse/github-actions-workflows/.github/workflows/deploy_container_image.yml@v0.52.0
with:
environment: production
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
deploy: false
image: ${{ needs.build.outputs.image }}
aws_ecr_iam_role_name: ECR_push_pull_images
secrets:
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}
update-images:
if: github.ref_name == 'main'
name: Update images
needs: [upload-production-image, upload-stage-image]
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ secrets.GH_BOT_APP_ID }}
private-key: ${{ secrets.GH_BOT_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: CloudProject
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: 'FlowFuse/CloudProject'
ref: 'main'
token: ${{ steps.generate_token.outputs.token }}
- name: Install yq
uses: alexellis/arkade-get@7cc6ec1b6d8fcfcf3cc8cac995973147bc5fabf7 # master
with:
yq: v4.42.1
- name: Update images
run: |
production_image_value="${{ secrets.PRODUCTION_AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.upload-production-image.outputs.image }}"
staging_image_value="${{ secrets.STAGING_AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.upload-stage-image.outputs.image }}"
yq e ".forge.image = \"$production_image_value\"" -i ./production/flowfuse-values.yaml
yq e ".forge.image = \"$staging_image_value\"" -i ./staging/flowfuse-values.yaml
git config --global user.name "GitHub Actions Bot"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./staging/flowfuse-values.yaml
git commit -m "Update forge staging image to ${{ needs.upload-stage-image.outputs.image }}"
git add ./production/flowfuse-values.yaml
git commit -m "Update forge production image to ${{ needs.upload-production-image.outputs.image }}"
git push origin main