Skip to content

Merge pull request #158 from dappforce/ded-and-pink #185

Merge pull request #158 from dappforce/ded-and-pink

Merge pull request #158 from dappforce/ded-and-pink #185

Workflow file for this run

name: Build and deploy frontend
on:
workflow_dispatch:
inputs:
back-address:
description: "Backend address to connect"
required: true
default: 'staging.sub.id'
push:
branches:
- main
- deploy/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
front-build:
strategy:
matrix:
apps: [production, deploy]
isMaster:
- ${{ contains(github.ref, 'main') }}
isDeploy:
- ${{ startsWith(github.ref, 'refs/heads/deploy/') }}
exclude:
- isMaster: false
apps: production
- isMaster: true
apps: deploy
name: Build ${{ matrix.apps }} Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Base ${{ matrix.apps }}
uses: './.github/actions/common-ci-setup'
with:
username_input: ${{ secrets.DOCKER_USERNAME }}
password_input: ${{ secrets.DOCKER_PASSWORD }}
app_input: ${{ matrix.apps }}
- name: Build production image
if: matrix.apps == 'production'
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/Dockerfile
push: true
build-args: |
GH_BACKEND_URL=https://sub.id
GH_IPFS_URL=https://ipfs.subsocial.network
GH_GA_ID=G-B4P7CHL1YE
GH_AMP_ID=d9f7a97f3cdc1eb7b4298af4f17c202b
tags: |
${{ env.image }}
docker.io/dappforce/subid-frontend:main-latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Build front image
if: matrix.apps == 'deploy'
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/Dockerfile
push: true
build-args: |
GH_BACKEND_URL=https://${{ github.event.inputs.back-address }}
GH_IPFS_URL=https://ipfs.subsocial.network
GH_GA_ID=fake
GH_AMP_ID=a4dc29d356f19fd9788f24b493b462bf
tags: |
${{ env.image }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
front-deploy:
strategy:
matrix:
apps: [production, deploy]
isMaster:
- ${{ contains(github.ref, 'main') }}
isDeploy:
- ${{ startsWith(github.ref, 'refs/heads/deploy/') }}
exclude:
- isMaster: false
apps: production
- isMaster: true
apps: deploy
name: deploy ${{ matrix.apps }}
needs: front-build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: make prod ready
if: matrix.apps == 'production'
uses: './.github/actions/common-cd-setup'
with:
token_input: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN_PROD }}
k8s_input: ${{ secrets.K8S_PROD }}
app_input: ${{ matrix.apps }}
zone_input: ${{ secrets.CF_ZONE }}
mail_input: ${{ secrets.CF_MAIL }}
tokens_input: ${{ secrets.CF_TOKEN }}
prod_deploy: "false"
- name: stage deploy ${{ matrix.apps }}
if: matrix.apps == 'deploy'
uses: './.github/actions/common-cd-setup'
with:
token_input: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN_STAGING }}
k8s_input: ${{ secrets.K8S_STAGING }}
app_input: ${{ matrix.apps }}
zone_input: ${{ secrets.CF_ZONE }}
mail_input: ${{ secrets.CF_MAIL }}
tokens_input: ${{ secrets.CF_TOKEN }}
prod_deploy: "false"