ci: switch from github actions to gitlab ci
This commit is contained in:
parent
ddddf0105a
commit
1ed5eb3e26
2 changed files with 67 additions and 129 deletions
129
.github/workflows/deploy-to-staging.yml
vendored
129
.github/workflows/deploy-to-staging.yml
vendored
|
|
@ -1,129 +0,0 @@
|
||||||
name: Deploy to staging from main branch
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags-ignore:
|
|
||||||
- '*' # ignore all tags
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: deploy-staging
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
env:
|
|
||||||
NAMESPACE: backoffice-staging
|
|
||||||
HELM_VERSION: "3.12.1"
|
|
||||||
DOCKER_REGISTRY: ghcr.io
|
|
||||||
DOCKER_IMAGE: vojtechmares/backoffice
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: ${{ github.ref }}
|
|
||||||
|
|
||||||
- name: set up qemu
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
|
|
||||||
- name: set up docker buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: docker login
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ${{ env.DOCKER_REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: docker meta
|
|
||||||
id: docker_meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
tags: |
|
|
||||||
type=schedule
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
type=ref,event=pr
|
|
||||||
type=sha,format=long
|
|
||||||
type=raw,value=${{ github.ref_name }}-${{ github.sha }}
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
||||||
images: |
|
|
||||||
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}
|
|
||||||
|
|
||||||
- name: build and push
|
|
||||||
uses: docker/build-push-action@v4
|
|
||||||
with:
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
||||||
# platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
||||||
cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment:
|
|
||||||
name: staging
|
|
||||||
url: https://staging.backoffice.mareshq.com
|
|
||||||
needs:
|
|
||||||
- build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: ${{ github.ref }}
|
|
||||||
|
|
||||||
# Setup kubectl and Helm for Azure
|
|
||||||
- uses: azure/setup-helm@v3
|
|
||||||
with:
|
|
||||||
version: "${{ env.HELM_VERSION }}"
|
|
||||||
|
|
||||||
- name: write kube config
|
|
||||||
run: |
|
|
||||||
mkdir -p $HOME/.kube/
|
|
||||||
echo "${{ secrets.KUBE_CONFIG }}" > $HOME/.kube/config
|
|
||||||
chmod 600 $HOME/.kube/config
|
|
||||||
|
|
||||||
- name: deploy dry run
|
|
||||||
run: |
|
|
||||||
helm upgrade \
|
|
||||||
--atomic \
|
|
||||||
--wait=true \
|
|
||||||
--wait-for-jobs=true \
|
|
||||||
--timeout 900s \
|
|
||||||
--dry-run=true \
|
|
||||||
--install \
|
|
||||||
--kube-context="kiwi" \
|
|
||||||
--namespace="${{ env.NAMESPACE }}" \
|
|
||||||
-f ./charts/backoffice/values.staging.yaml \
|
|
||||||
--set image.tag="${{ github.ref_name }}-${{ github.sha }}" \
|
|
||||||
--set backoffice.secrets.databaseURL="dummy" \
|
|
||||||
--set backoffice.secrets.nextauthSecret="dummy" \
|
|
||||||
--set backoffice.secrets.googleClientID="dummy" \
|
|
||||||
--set backoffice.secrets.googleClientSecret="dummy" \
|
|
||||||
backoffice \
|
|
||||||
./charts/backoffice
|
|
||||||
|
|
||||||
- name: deploy
|
|
||||||
run: |
|
|
||||||
helm upgrade \
|
|
||||||
--atomic \
|
|
||||||
--wait=true \
|
|
||||||
--wait-for-jobs=true \
|
|
||||||
--timeout 900s \
|
|
||||||
--dry-run=true \
|
|
||||||
--install \
|
|
||||||
--kube-context="kiwi" \
|
|
||||||
--namespace="${{ env.NAMESPACE }}" \
|
|
||||||
-f ./charts/backoffice/values.staging.yaml \
|
|
||||||
--set image.tag="${{ github.ref_name }}-${{ github.sha }}" \
|
|
||||||
--set backoffice.secrets.databaseURL="${{ secrets.DATABASE_URL }}" \
|
|
||||||
--set backoffice.secrets.nextauthSecret="${{ secrets.NEXTAUTH_SECRET }}" \
|
|
||||||
--set backoffice.secrets.googleClientID="${{ secrets.GOOGLE_CLIENT_ID }}" \
|
|
||||||
--set backoffice.secrets.googleClientSecret="${{ secrets.GOOGLE_CLIENT_SECRET }}" \
|
|
||||||
backoffice \
|
|
||||||
./charts/backoffice
|
|
||||||
67
.gitlab-ci.yml
Normal file
67
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
default:
|
||||||
|
image: registry.mareshq.com/mareshq/ci-toolkit:latest
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
docker:build:
|
||||||
|
stage: build
|
||||||
|
before_script:
|
||||||
|
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
|
||||||
|
- docker info
|
||||||
|
script:
|
||||||
|
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA .
|
||||||
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
|
||||||
|
|
||||||
|
deploy:staging:dry-run:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- >
|
||||||
|
helm \
|
||||||
|
upgrade \
|
||||||
|
--install \
|
||||||
|
--atomic \
|
||||||
|
--wait=true \
|
||||||
|
--wait-for-jobs=true \
|
||||||
|
--timeout=900s \
|
||||||
|
--dry-run=true \
|
||||||
|
--namespace backoffice-staging \
|
||||||
|
--values ./charts/backoffice/values.staging.yaml \
|
||||||
|
--set image.tag=$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA \
|
||||||
|
--set backoffice.secrets.databaseURL=dummy \
|
||||||
|
--set backoffice.secrets.nextauthSecret=dummy \
|
||||||
|
--set backoffice.secrets.googleClientID=dummy \
|
||||||
|
--set backoffice.secrets.googleClientSecret=dummy \
|
||||||
|
backoffice \
|
||||||
|
./charts/backoffice
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
|
when: always
|
||||||
|
|
||||||
|
deploy:staging:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- >
|
||||||
|
helm \
|
||||||
|
upgrade \
|
||||||
|
--install \
|
||||||
|
--atomic \
|
||||||
|
--wait=true \
|
||||||
|
--wait-for-jobs=true \
|
||||||
|
--timeout=900s \
|
||||||
|
--namespace backoffice-staging \
|
||||||
|
--values ./charts/backoffice/values.staging.yaml \
|
||||||
|
--set image.tag=$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA \
|
||||||
|
--set backoffice.secrets.databaseURL=$DATABASE_URL \
|
||||||
|
--set backoffice.secrets.nextauthSecret=$NEXTAUTH_SECRET \
|
||||||
|
--set backoffice.secrets.googleClientID=$GOOGLE_CLIENT_ID \
|
||||||
|
--set backoffice.secrets.googleClientSecret=$GOOGLE_CLIENT_SECRET \
|
||||||
|
backoffice \
|
||||||
|
./charts/backoffice
|
||||||
|
environment:
|
||||||
|
name: staging
|
||||||
|
url: https://staging.backoffice.mareshq.com
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
|
when: always
|
||||||
Reference in a new issue