[ci] Migrate CI from GitLab to GitHub (#593)

* [ci] Migrate CI from GitLab to GitHub

* fix docker path

* unite backend jobs into one workflow

* rm files

* add cache-on-failure to tests cache

* add deploy workflow

* change wfl name

* readme

* fix readme

* typo
This commit is contained in:
Alexander Samusev
2024-10-29 11:57:11 +01:00
committed by GitHub
parent 0cd8726ce5
commit b16ad2e8ad
11 changed files with 334 additions and 422 deletions
+109
View File
@@ -0,0 +1,109 @@
name: Backend CI
on:
push:
branches:
- master
paths:
- ".github/workflows/backend*"
- "backend/**"
- "!frontend/**"
pull_request:
paths:
- ".github/workflows/backend*"
- "backend/**"
- "!frontend/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: ./backend
jobs:
check:
name: Check Code
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
- name: Build
run: cargo check --all-targets --verbose
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
cache-on-failure: true
- name: Cargo test
run: cargo test --verbose --jobs 1
docs:
name: Check Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
- name: Check internal documentation links
run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items
fmt:
name: Run rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy, rustfmt
- name: Cargo fmt
run: cargo fmt --verbose --all -- --check
-45
View File
@@ -1,45 +0,0 @@
name: Backend CI - cargo check
on:
push:
branches:
- master
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
pull_request:
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: ./backend
jobs:
check:
name: Check Code
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
- name: Build
run: cargo check --all-targets --verbose
-45
View File
@@ -1,45 +0,0 @@
name: Backend CI - cargo doc
on:
push:
branches:
- master
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
pull_request:
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: ./backend
jobs:
docs:
name: Check Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
- name: Check internal documentation links
run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items
-41
View File
@@ -1,41 +0,0 @@
name: Backend CI - cargo fmt
on:
push:
branches:
- master
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
pull_request:
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: ./backend
jobs:
fmt:
name: Run rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy, rustfmt
- name: Cargo fmt
run: cargo fmt --verbose --all -- --check
-45
View File
@@ -1,45 +0,0 @@
name: Backend CI - cargo test
on:
push:
branches:
- master
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
pull_request:
paths:
- '.github/workflows/backend*'
- 'backend/**'
- '!frontend/**'
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: ./backend
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
workspaces: backend
- name: Cargo test
run: cargo test --verbose --jobs 1
+73
View File
@@ -0,0 +1,73 @@
name: Docker Build
# Workflow checks that docker build works
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: parity/substrate-telemetry
jobs:
set-variables:
name: Set variables
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Define version
id: version
run: |
export COMMIT_SHA=${{ github.sha }}
export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8}
export REF_NAME=${{ github.ref_name }}
export REF_SLUG=${REF_NAME//\//_}
if [[ ${REF_SLUG} == "main" ]]
then
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
else
echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT
fi
echo "set VERSION=${VERSION}"
build_backend:
name: Build backend docker image
runs-on: ubuntu-latest
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build and push Docker image from main
uses: docker/build-push-action@v5
with:
context: backend
file: ./backend/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}-backend:${{ env.VERSION }}
build_frontend:
name: Build frontend docker image
runs-on: ubuntu-latest
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build and push Docker image from main
uses: docker/build-push-action@v5
with:
context: frontend
file: ./frontend/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}-frontend:${{ env.VERSION }}
+4
View File
@@ -15,6 +15,10 @@ on:
- 'frontend/**'
- '!backend/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ./frontend
-22
View File
@@ -1,22 +0,0 @@
name: gitspiegel sync
# This workflow doesn't do anything, it's only use is to trigger "workflow_run"
# webhook, that'll be consumed by gitspiegel
# This way, gitspiegel won't do mirroring, unless this workflow runs,
# and running the workflow is protected by GitHub
on:
pull_request:
types:
- opened
- synchronize
- unlocked
- ready_for_review
- reopened
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Do nothing
run: echo "let's go"
+136
View File
@@ -0,0 +1,136 @@
name: Publish and deploy
on:
push:
branches:
- master
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: parity/substrate-telemetry
APP: "substrate-telemetry"
jobs:
set-variables:
name: Set variables
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Define version
id: version
run: |
export COMMIT_SHA=${{ github.sha }}
export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8}
export REF_NAME=${{ github.ref_name }}
export REF_SLUG=${REF_NAME//\//_}
if [[ ${REF_SLUG} == "master" ]]
then
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
else
echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT
fi
echo "set VERSION=${VERSION}"
build_backend:
name: Build backend docker image
runs-on: ubuntu-latest
needs: [set-variables]
environment: master_n_tags
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image from master
uses: docker/build-push-action@v5
with:
context: backend
file: ./backend/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}-backend:${{ env.VERSION }}
build_frontend:
name: Build frontend docker image
runs-on: ubuntu-latest
needs: [set-variables]
environment: master_n_tags
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image from master
uses: docker/build-push-action@v5
with:
context: frontend
file: ./frontend/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}-frontend:${{ env.VERSION }}
deploy-stg:
name: Deploy Staging
runs-on: ubuntu-latest
needs: [set-variables, build_backend, build_frontend]
environment: parity-stg
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "argocd-stg.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-stg"
tag: "${{ env.VERSION }}"
app_name: "${{ env.APP }}"
app_packages: "frontend,backend"
argocd_additional_args: "-p substrate-telemetry.image.backend.repository=docker.io/parity/substrate-telemetry-backend -p substrate-telemetry.image.frontend.repository=docker.io/parity/substrate-telemetry-frontend"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-stg"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}
deploy-prod:
name: Deploy Production
runs-on: ubuntu-latest
needs: [set-variables, deploy-stg]
environment: parity-prod
# Deploy only if the tag is v*
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "argocd-prod.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-prod"
tag: "${{ env.VERSION }}"
app_name: "${{ env.APP }}"
app_packages: "frontend,backend"
argocd_additional_args: "-p substrate-telemetry.image.backend.repository=docker.io/parity/substrate-telemetry-backend -p substrate-telemetry.image.frontend.repository=docker.io/parity/substrate-telemetry-frontend"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-prod"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}
-213
View File
@@ -1,213 +0,0 @@
# Gitlab-CI Workflow
# stages:
# build:
# - Runs on commits on master or tags that match the pattern "v[0-9]+\.[0-9]+.*$". (e.g. 1.0, v2.1rc1)
# deploy-staging:
# - Runs on commits on master or tags that match the pattern v1.0, v2.1rc1 (continues deployment)
# deploy-production:
# - Runs on tags that match the pattern v1.0, v2.1rc1 (manual deployment)
variables:
# Build Variables (Mandatory)
CONTAINER_REPO: ""
DOCKERFILE_DIRECTORY: ""
# Manual Variables (Optional)
## Could be used in the webconsole when triggering the pipeline manually
## DO NOT SET THEM IN THIS FILE!! They've been mentioned here only for documentation purposes!
FORCE_DEPLOY: "" # boolean: true or false - triggers the deploy-production stage
FORCE_DOCKER_TAG: "" # choose an existing docker tag to be deployed (e.g. v1.2.3)
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.29"
BUILDAH_COMMAND: "buildah --storage-driver overlay2"
default:
before_script:
- |-
echo defining DOCKER_IMAGE_TAG variable
if [[ $FORCE_DOCKER_TAG ]]; then
export DOCKER_IMAGE_TAG="${FORCE_DOCKER_TAG}"
elif [[ $CI_COMMIT_TAG =~ ^v[0-9]+\.[0-9]+.*$ ]]; then
export DOCKER_IMAGE_TAG="${CI_COMMIT_TAG}"
export BUILD_LATEST_IMAGE="true"
else
export DOCKER_IMAGE_TAG="${CI_COMMIT_SHORT_SHA}-beta"
fi
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
stages:
- build
- deploy-commit-to-staging
- deploy-master-to-staging
- deploy-production
# Pipeline Job Templates:
.dockerize: &dockerize
stage: build
image: $BUILDAH_IMAGE
script:
- |-
echo building "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
if [[ $BUILD_LATEST_IMAGE ]]; then
$BUILDAH_COMMAND build \
--format=docker \
--tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" \
--tag "$CONTAINER_REPO:latest" "$DOCKERFILE_DIRECTORY"
else
$BUILDAH_COMMAND build \
--format=docker \
--tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" "$DOCKERFILE_DIRECTORY"
fi
- echo ${DOCKER_PASSWORD} |
buildah login --username ${DOCKER_USERNAME} --password-stdin docker.io
- |-
echo pushing "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
if [[ $BUILD_LATEST_IMAGE ]]; then
$BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
$BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:latest"
else
$BUILDAH_COMMAND push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
fi
rules:
- if: '$FORCE_DOCKER_TAG'
when: never
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
when: always
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
tags:
- kubernetes-parity-build
.publish-docker-image-description:
stage: build
image: paritytech/dockerhub-description
before_script:
- echo
variables:
DOCKERHUB_REPOSITORY: parity/substrate-telemetry-$PRODUCT
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
README_FILEPATH: $CI_PROJECT_DIR/$PRODUCT/Dockerfile.README.md
rules:
- if: $CI_COMMIT_REF_NAME == "master"
changes:
- $PRODUCT/Dockerfile.README.md
script:
- cd / && sh entrypoint.sh
tags:
- kubernetes-parity-build
.deploy: &deploy
image: quay.io/argoproj/argocd:v2.7.9
variables:
ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$ENVIRONMENT
APP: substrate-telemetry
environment:
name: $ENVIRONMENT
script:
- argocd app list
- argocd app set $APP
--helm-set substrate-telemetry.image.backend.repository="${CONTAINER_REPO_BACKEND}"
--helm-set substrate-telemetry.image.backend.tag="${DOCKER_IMAGE_TAG}"
--helm-set substrate-telemetry.image.frontend.repository="${CONTAINER_REPO_FRONTEND}"
--helm-set substrate-telemetry.image.frontend.tag="${DOCKER_IMAGE_TAG}"
- argocd app sync $APP
- argocd app wait $APP --timeout 180
tags:
- kubernetes-parity-build
# Pipeline Jobs:
build-backend:
variables:
CONTAINER_REPO: "docker.io/parity/substrate-telemetry-backend"
DOCKERFILE_DIRECTORY: "./backend/"
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
<<: *dockerize
build-frontend:
variables:
CONTAINER_REPO: "docker.io/parity/substrate-telemetry-frontend"
DOCKERFILE_DIRECTORY: "./frontend/"
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
<<: *dockerize
publish-backend-docker-image-description:
extends: .publish-docker-image-description
variables:
PRODUCT: backend
SHORT_DESCRIPTION: "substrate-backend Docker Image."
publish-frontend-docker-image-description:
extends: .publish-docker-image-description
variables:
PRODUCT: frontend
SHORT_DESCRIPTION: "substrate-frontend Docker Image."
# Manually build the docker images and deploy some commit to staging.
build-backend-manual:
variables:
CONTAINER_REPO: "docker.io/paritypr/substrate-telemetry-backend"
DOCKERFILE_DIRECTORY: "./backend/"
DOCKER_USERNAME: $PARITYPR_USER
DOCKER_PASSWORD: $PARITYPR_PASS
<<: *dockerize
rules:
- if: '$CI_COMMIT_BRANCH =~ /^[0-9]+/'
when: manual
build-frontend-manual:
variables:
CONTAINER_REPO: "docker.io/paritypr/substrate-telemetry-frontend"
DOCKERFILE_DIRECTORY: "./frontend/"
DOCKER_USERNAME: $PARITYPR_USER
DOCKER_PASSWORD: $PARITYPR_PASS
<<: *dockerize
rules:
- if: '$CI_COMMIT_BRANCH =~ /^[0-9]+/'
when: manual
deploy-commit-to-staging:
variables:
CONTAINER_REPO_BACKEND: "docker.io/paritypr/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/paritypr/substrate-telemetry-frontend"
ENVIRONMENT: "parity-stg"
stage: deploy-commit-to-staging
extends: .deploy
rules:
- if: '$CI_COMMIT_BRANCH =~ /^[0-9]+/'
when: manual
# Automatically deploy `master` branch or tag like `v1.0` to staging
deploy-master-to-staging:
variables:
CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend"
ENVIRONMENT: "parity-stg"
stage: deploy-master-to-staging
extends: .deploy
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# Manually deploy a tag like `v1.0` to production
deploy-production:
variables:
CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend"
ENVIRONMENT: "parity-prod"
stage: deploy-production
extends: .deploy
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
when: manual
- if: '$FORCE_DEPLOY == "true"'
when: manual
+12 -11
View File
@@ -193,9 +193,9 @@ This section covers the internal deployment of Substrate Telemetry to our stagin
Every time new code is merged to `master`, a new version of telemetry will be automatically built and deployed to our staging environment, so there is nothing that you need to do. Roughly what will happen is:
- An image tag will be generated that looks like `$CI_COMMIT_SHORT_SHA-beta`, for example `224b1fae-beta`.
- An image tag will be generated that looks like `master-$CI_COMMIT_SHORT_SHA`, for example `master-224b1fae`.
- Docker images for the frontend and backend will be pushed to the docker repo (see https://hub.docker.com/r/parity/substrate-telemetry-backend/tags?page=1&ordering=last_updated and https://hub.docker.com/r/parity/substrate-telemetry-frontend/tags?page=1&ordering=last_updated).
- A deployment to the staging environment will be performed using these images. Go to https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines to inspect the progress of such deployments.
- A deployment to the staging environment will be performed using these images. Go to https://github.com/paritytech/substrate-telemetry/actions to inspect the progress of such deployments.
### Deployment to live
@@ -205,18 +205,19 @@ Once we're happy with things in staging, we can do a deployment to live as follo
2. Tag the commit on `master` that you'd like to deploy with the form `v1.0-a1b2c3d`.
- The version number (`1.0` here) should just be incremented from whatever the latest version found using `git tag` is. We don't use semantic versioning or anything like that; this is just a dumb "increment version number" approach so that we can see clearly what we've deployed to live and in what order.
- The suffix is a short git commit hash (which can be generated with `git rev-parse --short HEAD`), just so that it's really easy to relate the built docker images back to the corresponding code.
3. Pushing the tag (eg `git push origin v1.0-a1b2c3d`) will kick off the deployment process, which in this case will also lead to new docker images being built. You can view the progress at https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines.
3. Pushing the tag (eg `git push origin v1.0-a1b2c3d`) will kick off the deployment process, which in this case will also lead to new docker images being built. You can view the progress at https://github.com/paritytech/substrate-telemetry/actions.
> [!WARNING]
> After the tag is pushed the deploy will be done to both environments (staging and production) automatically.
4. Once a deployment to staging has been successful, run whatever tests you need against the staging deployment to convince yourself that you're happy with it.
5. Visit the CI/CD pipelines page again (URl above) and click the "play" button on the "Deploy-production" stage to perform the deployment to live.
6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.
5. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.
### Rolling back to a previous deployment
If something goes wrong running the above, we can roll back the deployment to live as follows.
1. Decide what image tag you'd like to roll back to. Go to https://hub.docker.com/r/parity/substrate-telemetry-backend/tags?page=1&ordering=last_updated and have a look at the available tags (eg `v1.0-a1b2c3d`) to select one you'd like. You can cross reference this with the tags available using `git tag` in the repository to help see which tags correspond to which code changes.
2. Navigate to https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines/new.
3. Add a variable called `FORCE_DEPLOY` with the value `true`.
4. Add a variable called `FORCE_DOCKER_TAG` with a value corresponding to the tag you want to deploy, eg `v1.0-a1b2c3d`. Images must exist already for this tag.
5. Hit 'Run Pipeline'. As above, a deployment to staging will be carried out, and if you're happy with that, you can hit the "play" button on the "Deploy-production" stage to perform the deployment to live.
6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.
1. Decide what image tag you'd like to roll back to. Push the tag to the commit you want to revert to.
2. Navigate to https://github.com/paritytech/substrate-telemetry/actions and check that the pipeline is successful.
3. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.
4. In case of issues contact devops team.