Skip to content

Commit

Permalink
[v10] add webassets automation (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmb3 authored Aug 3, 2022
1 parent 5e95fad commit 9aaafa6
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
11 changes: 11 additions & 0 deletions web/.github/actions/docker-build-webassets/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: docker-build-webassets
author: Zac Bergquist <[email protected]>
description: Build Teleport webassets in Docker

runs:
using: docker
image: ../../../Dockerfile
entrypoint: sh
args:
- -c
- yarn install && yarn run build-teleport
57 changes: 57 additions & 0 deletions web/.github/workflows/update-webassets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update Webassets

on:
push:
branches:
- master
- teleport-v**

jobs:
build:
runs-on: ubuntu-latest

steps:
# Get webapps, and the webapps.e submodule
- name: Checkout webapps
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
submodules: recursive
fetch-depth: 0

# Get webassets, and the webassets.e submodule
- name: Checkout webassets
uses: actions/checkout@v3
with:
repository: gravitational/webassets
path: dist
ref: ${{ github.ref_name }}
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
submodules: recursive
fetch-depth: 0

# This workflow only runs on push to a protected branch, so the code
# has already been reviewed and is trusted. This means it is safe to
# the version of the action that we checked out and we don't need to
# always use master.
- name: Build webassets
uses: ./.github/actions/docker-build-webassets

- name: Push updates
run: |
git config --global user.email [email protected]
git config --global user.name "$GITHUB_ACTOR"
echo "Updating webassets.e"
cd dist/e
git add -A
git status
git commit -m "Update webassets.e from gravitational/webapps@$GITHUB_SHA" --allow-empty
git push origin HEAD:$GITHUB_REF_NAME
echo "Updating webassets"
cd ..
git add -A
git status
git commit -m "Update webassets from gravitational/webapps@$GITHUB_SHA" --allow-empty
git push origin HEAD:$GITHUB_REF_NAME
2 changes: 1 addition & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN if [ -n "$YARN_FROZEN_LOCKFILE" ]; then \

# copy the rest of the files and run yarn build command
COPY . .
ARG NPM_SCRIPT
ARG NPM_SCRIPT=nop
ARG OUTPUT
# run npm script with optional --output-path parameter
RUN yarn $NPM_SCRIPT $([ -z $OUTPUT ] || echo --output-path=$OUTPUT)
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"build-e": "yarn build-teleport-e",
"type-check-and-lint": "yarn type-check && yarn lint",
"lint": "eslint --ext .js,.jsx,.ts,.tsx packages/",
"type-check": "tsc --noEmit"
"type-check": "tsc --noEmit",
"nop": "exit 0"
},
"private": true,
"resolutions": {
Expand Down

0 comments on commit 9aaafa6

Please sign in to comment.