Skip to content

Commit

Permalink
[ci] Move CI from GitLab to GitHub (#147)
Browse files Browse the repository at this point in the history
* [ci] Move CI from GitLab to GitHub

* use ubuntu-latest runners

* fix ref_name

* take version from output

* put version in env

* try another format

* fix set-variables

* rm gitlab ci, add concurrency

* add deploy

* permissions

* add envs

* apps

* app
  • Loading branch information
alvicsam authored Oct 29, 2024
1 parent 3a76056 commit fd57ff0
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 156 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

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: paritytech/testnet-manager

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_image:
name: Build 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: .
file: ./Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
22 changes: 0 additions & 22 deletions .github/workflows/gitspiegel-trigger.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/publish_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Deploy

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

#to use reusable workflow
permissions:
id-token: write
contents: read

env:
IMAGE_NAME: paritytech/testnet-manager
APP: "testnet-manager"

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}"
docker-publish:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
environment: main
needs: [set-variables]
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_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Build and push Docker image from main
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
deploy-versi:
name: Deploy Versi
runs-on: ubuntu-latest
environment: parity-versi
needs: [set-variables, docker-publish]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "versi-argocd.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-versi"
tag: "${{ env.VERSION }}"
app_name: "${{ env.APP }}"
app_packages: "${{ env.APP }}"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "versi-argocd"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}

deploy-westend:
name: Deploy Westend
runs-on: ubuntu-latest
environment: parity-testnet
needs: [set-variables, docker-publish]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "westend-argocd.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-testnet"
tag: "${{ env.VERSION }}"
app_name: "testnet-manager-westend"
app_packages: "testnet-manager-westend"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-testnet"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}
12 changes: 7 additions & 5 deletions .github/workflows/smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ name: Run smoke test

on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
smoke_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install minikube helmfile and plugins
run : |
- name: Install minikube helmfile and plugins
run: |
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
install minikube-linux-amd64 /usr/local/bin/minikube
minikube version
Expand All @@ -20,7 +23,7 @@ jobs:
helm plugin install https://github.com/databus23/helm-diff
- name: setup
run : |
run: |
cd local-kubernetes
make kube
make install
Expand All @@ -29,7 +32,7 @@ jobs:
kubectl get pod -n rococo
- name: Tests
run : |
run: |
pwd
(cd local-kubernetes && make web-ci)
pwd
Expand All @@ -39,4 +42,3 @@ jobs:
with:
name: web
path: output

6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Run tests

on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-22.04
Expand All @@ -21,7 +25,7 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Run tests
run : |
run: |
# PyYaml is required until docker-compose is migrated to v2
pip install pyyaml==5.3.1
pip install docker==6.1.3 docker-compose
Expand Down
128 changes: 0 additions & 128 deletions .gitlab-ci.yml

This file was deleted.

0 comments on commit fd57ff0

Please sign in to comment.