Skip to content

Commit

Permalink
Feature: Deploys
Browse files Browse the repository at this point in the history
Adds a sub-workflow which can be dispatched generically to deploy
an Elide sample or app.

Changes enclosed:
- Add deployment sub-workflow
- Use it from regular build
  • Loading branch information
sgammon committed Nov 18, 2022
1 parent bfc32df commit 100e549
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 40 deletions.
60 changes: 49 additions & 11 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
frontend:
- any: ["graalvm*/**/*"]
all: ["module:graalvm"]
- any: ["frontend/**/*"]
all: ["module:frontend"]
- any: ["rpc/**/*"]
all: ["module:rpc"]
- any: ["server/**/*"]
all: ["module:server"]
- any: ["base/**/*"]
all: ["module:base"]
#
# Labels: Generic
#
"tools":
- any: ["tools/**/*"]
"release":
- all: [".version", "README.md"]

#
# Labels: Platform
#
"platform:jvm":
- any: ["packages/base/**/*"]
- any: ["packages/graalvm/**/*"]
- any: ["packages/model/**/*"]
- any: ["packages/rpc/**/*", "packages/rpc-jvm/**/*"]
- any: ["packages/server/**/*"]
"platform:browser":
- any: ["packages/base/**/*"]
- any: ["packages/frontend/**/*"]

#
# Labels: Modules
#
"module:base":
- any: ["packages/base/**/*"]
"module:graalvm":
- any:
[
"packages/graalvm/**/*",
"packages/graalvm-js/**/*",
"packages/graalvm-react/**/*",
]
"module:model":
- any: ["packages/model/**/*"]
"module:rpc":
- any: ["packages/rpc/**/*", "packages/rpc-jvm/**/*", "packages/rpc-js/**/*"]
"module:server":
- any: ["packages/server/**/*"]
"module:frontend":
- any: ["packages/frontend/**/*"]

#
# Labels: CI Triggers
#
"ci:build-img-jvm":
- any: ["samples/**/*.kt"]
"ci:build-img-native":
- any: ["samples/**/*.kt"]
51 changes: 22 additions & 29 deletions .github/workflows/build.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
license-check: true
vulnerability-check: true
fail-on-severity: "low"
base-ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'v3' }}
- name: "Patch: Restore Yarn Lock"
run: mv kotlin-js-store/yarn.inert kotlin-js-store/yarn.lock

Expand Down Expand Up @@ -285,6 +286,7 @@ jobs:
if: |
(
github.ref == 'refs/heads/stable' ||
github.ref == 'refs/heads/v3' ||
contains(github.event.pull_request.labels.*.name, 'ci:test-native') ||
contains(github.event.head_commit.message, 'ci:test-native') ||
startsWith(github.ref, 'refs/tags/v')
Expand Down Expand Up @@ -370,6 +372,7 @@ jobs:
if: |
(
github.ref == 'refs/heads/stable' ||
github.ref == 'refs/heads/v3' ||
contains(github.event.pull_request.labels.*.name, 'ci:build-img-jvm') ||
contains(github.event.head_commit.message, 'ci:build-img-jvm') ||
startsWith(github.ref, 'refs/tags/v')
Expand Down Expand Up @@ -470,6 +473,7 @@ jobs:
if: |
(
github.ref == 'refs/heads/stable' ||
github.ref == 'refs/heads/v3' ||
contains(github.event.pull_request.labels.*.name, 'ci:build-img-native') ||
contains(github.event.head_commit.message, 'ci:build-img-native') ||
startsWith(github.ref, 'refs/tags/v')
Expand Down Expand Up @@ -563,46 +567,35 @@ jobs:
##

deploy-samples:
strategy:
matrix:
category: [fullstack]
app: [react-ssr]
variant: [jvm]

name: "Deploy"
runs-on: ubuntu-latest
needs: [gradle, tests-jvm, tests-native, docker-jvm, docker-native]
needs: [gradle, tests-jvm, docker-jvm, docker-native]
if: |
(
github.ref == 'refs/heads/stable' ||
github.ref == 'refs/heads/v3' ||
contains(github.event.pull_request.labels.*.name, 'ci:deploy-samples') ||
contains(github.event.head_commit.message, 'ci:deploy-samples') ||
startsWith(github.ref, 'refs/tags/v')
)
strategy:
matrix:
category: [fullstack]
app: [react-ssr]
variant: [jvm]

permissions:
contents: "read"
id-token: "write"
checks: "write"
pull-requests: "write"

steps:
## Setup: Checkout Code
- name: "Setup: Checkout"
uses: actions/checkout@v3

## Setup: Fly
- name: "Setup: Fly"
uses: superfly/flyctl-actions/setup-flyctl@master

- name: "Deploy: ${{ matrix.sample }} (${{ matrix.variant }})"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
SAMPLE_CATEGORY: ${{ matrix.category }}
SAMPLE_APP: ${{ matrix.app }}
SAMPLE_VARIANT: ${{ matrix.variant }}
run: |
cd samples/$SAMPLE_CATEGORY/$SAMPLE_APP && \
flyctl deploy \
--remote-only \
--image "us-docker.pkg.dev/elide-fw/samples/$SAMPLE_CATEGORY/$SAMPLE_APP/$SAMPLE_VARIANT:opt-latest";
deployments: "write"
statuses: "write"

uses: elide-dev/v3/.github/workflows/deploy.ci.yml@v3-deploys
secrets: inherit
with:
path: "samples/${{ matrix.category }}/${{ matrix.app }}"
image: "us-docker.pkg.dev/elide-fw/samples/${{ matrix.category }}/${{ matrix.app }}/${{ matrix.variant }}:opt-latest"
environment: samples
url: https://${{ matrix.app }}.samples.elide.dev
92 changes: 92 additions & 0 deletions .github/workflows/deploy.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Deployment

concurrency:
group: "deploy"
cancel-in-progress: false

on:
## Deployment can be invoked from other workflows.
workflow_call:
inputs:
## Path to the app to deploy.
path:
description: "Path"
required: true
default: "samples/fullstack/react-ssr"
type: string

## Environment to update with this deployment.
environment:
description: "Target"
type: string
required: true

## URL target for this deployment.
url:
description: "URL"
type: string
required: true

## Optional image tag to deploy. If not specified, the "latest" image will be deployed.
image:
description: "Image"
type: string
required: false

secrets:
FLY_API_TOKEN:
required: true

## Deployment can be triggered manually.
workflow_dispatch:
inputs:
path:
description: "Site"
required: true
default: "samples/fullstack/react-ssr"
type: choice
options:
- samples/fullstack/react-ssr
environment:
description: "Target"
type: environment
required: true
url:
description: "URL"
type: string
required: true
image:
description: "Image"
type: string
required: false

jobs:
deployment:
name: "Deploy (${{ inputs.environment }})"
runs-on: "ubuntu-latest"
environment: ${{ inputs.environment }}
concurrency: "deploy-${{ inputs.environment }}"
permissions:
contents: "read"
id-token: "write"
checks: "write"
pull-requests: "write"
statuses: "write"
deployments: "write"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
steps:
## Setup: Checkout Code
- name: "Setup: Checkout"
uses: actions/checkout@v3

## Setup: Fly
- name: "Setup: Fly"
uses: superfly/flyctl-actions/setup-flyctl@master

## Deploy: App
- name: "Deploy: Fly (${{ inputs.environment }})"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
cd ${{ inputs.path }} && flyctl deploy --remote-only ${{ inputs.image != '' && format('--image {0}', inputs.image) || '' }};

0 comments on commit 100e549

Please sign in to comment.