This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
120 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Continuous Deployment templates staging | ||
|
||
on: | ||
repository_dispatch: | ||
types: [template-updated] | ||
|
||
env: | ||
GKE_CLUSTER: susbtrate-playground-staging | ||
GKE_ZONE: us-central1-a | ||
DOCKER_BUILDKIT: 1 | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# https://github.com/actions/checkout | ||
- uses: actions/checkout@v2 | ||
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master | ||
with: | ||
# GCLOUD_KEY is the base64 of the gcloud service account JSON file | ||
# Get the JSON file from https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=1&hl=fr&project=substrateplayground-252112&folder=&organizationId=&supportedpurview=project | ||
# ... -> Actions -> Create Key | ||
# then base64 substrateplayground-XXX.json | tr -d \\n | ||
service_account_key: ${{ secrets.GCLOUD_KEY }} | ||
export_default_credentials: true | ||
project_id: ${{ secrets.GKE_PROJECT }} | ||
- run: gcloud --quiet auth configure-docker | ||
- run: gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE" | ||
- run: echo "::set-env name=ACCESS_TOKEN::$(gcloud auth print-access-token)" | ||
|
||
- name: Create template Dockerfile | ||
run: cat templates/Dockerfile.template | sed -e "s/\%IMAGE%/${{ github.event.client_payload.image }}/" > Dockerfile.theia | ||
|
||
- name: Build and Push template image on GKE | ||
uses: docker/build-push-action@v1 # https://github.com/docker/build-push-action | ||
with: | ||
username: oauth2accesstoken | ||
password: ${{ env.ACCESS_TOKEN }} | ||
dockerfile: Dockerfile.theia | ||
repository: substrateplayground-252112/jeluard/substrate-playground-template-${{ github.event.repository.name }}-theia | ||
registry: gcr.io | ||
tags: latest | ||
add_git_labels: true | ||
tag_with_ref: true | ||
tag_with_sha: true | ||
|
||
- name: Build and Push template image | ||
uses: docker/build-push-action@v1 # https://github.com/docker/build-push-action | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
dockerfile: Dockerfile.theia | ||
repository: jeluard/substrate-playground-template-${{ github.event.repository.name }}-theia | ||
tags: latest | ||
add_git_labels: true | ||
tag_with_ref: true | ||
tag_with_sha: true | ||
|
||
- run: echo ::set-output name=sha::sha-${GITHUB_SHA::7} | ||
id: env | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install yq | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install yq | ||
- name: Update template version | ||
run: cat <<< "$(yq -y ".image = gcr.io/substrateplayground-252112/$IMAGE" < conf/k8s/overlays/staging/template/${{ github.event.repository.name }})" > conf/k8s/overlays/staging/template/${{ github.event.repository.name }} | ||
|
||
- name: Commit template version update | ||
uses: EndBug/add-and-commit@v4 | ||
with: | ||
message: ":bookmark: update template version for ${{ github.event.repository.name }}" | ||
add: conf/k8s/overlays/staging/template/${{ github.event.repository.name }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ steps.env.outputs.sha }} | ||
release_name: ${{ steps.env.outputs.sha }} | ||
body: | | ||
Template release: | ||
- paritytech/substrate-playground-template-${{ github.event.repository.name }}:${{ steps.env.outputs.sha }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# TODO update the sha from other build steps | ||
FROM jeluard/substrate-playground-template-theia-base@sha256:6c4c0389d1f91a7debcd8bea74f33bd8a8ae3612bea60e1c985c273ccd96a52d as theia-base | ||
|
||
# Will be replaced by the image remotely built | ||
FROM %IMAGE% | ||
|
||
# Copy the whole theia folder, including node_modules | ||
# This is the recommended approach: https://spectrum.chat/theia/dev/theia-packaging~6c10127c-a316-4e87-9a27-e4b70fb647c1 | ||
COPY --from=theia-base --chown=substrate:substrate /home/theia /home/theia | ||
|
||
# Use the instance hostname for webviews. | ||
# By default theia uses a unique domain per webview byt this is not a security consideration here. | ||
# See: | ||
# * https://github.com/eclipse-theia/theia/blob/master/CHANGELOG.md#v0130 | ||
# * https://github.com/eclipse-theia/theia/pull/6465#issuecomment-557494879 | ||
# * https://spectrum.chat/theia/dev/any-breaking-changes-made-recently-to-webview~e5bd31a3-eee7-4288-b092-cf7407468780 | ||
ENV THEIA_WEBVIEW_EXTERNAL_ENDPOINT={{hostname}} | ||
|
||
WORKDIR /home/theia/theia-playground/ | ||
|
||
ENTRYPOINT [ "dumb-init", "node", "--always-compact", "--max-old-space-size=64", "src-gen/backend/main.js", "/home/substrate/workspace", "--hostname=0.0.0.0" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters