This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: build and deploy
|
name: deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,42 +6,43 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-deploy:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
|
||||||
steps:
|
container:
|
||||||
- name: Checkout
|
image: docker:27-cli
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Login to registry
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login ${{ secrets.REGISTRY_HOST }} -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
||||||
|
|
||||||
- name: Build image
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ secrets.REGISTRY_HOST }}/mintel/mb-grid-solutions:latest .
|
|
||||||
|
|
||||||
- name: Push image
|
|
||||||
run: |
|
|
||||||
docker push ${{ secrets.REGISTRY_HOST }}/mintel/mb-grid-solutions:latest
|
|
||||||
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: build
|
|
||||||
runs-on: self-hosted
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup SSH
|
- name: install tools
|
||||||
|
run: |
|
||||||
|
apk add --no-cache git openssh
|
||||||
|
|
||||||
|
- name: clone repo
|
||||||
|
run: |
|
||||||
|
git clone https://git.infra.mintel.me/mmintel/mb-grid-solutions.com .
|
||||||
|
git checkout main
|
||||||
|
|
||||||
|
- name: login to registry
|
||||||
|
env:
|
||||||
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
REGISTRY_PASS: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
run: |
|
||||||
|
echo "$REGISTRY_PASS" | docker login registry.infra.mintel.me -u "$REGISTRY_USER" --password-stdin
|
||||||
|
|
||||||
|
- name: build image
|
||||||
|
run: |
|
||||||
|
docker build -t registry.infra.mintel.me/mintel/mb-grid-solutions:latest .
|
||||||
|
|
||||||
|
- name: push image
|
||||||
|
run: |
|
||||||
|
docker push registry.infra.mintel.me/mintel/mb-grid-solutions:latest
|
||||||
|
|
||||||
|
- name: deploy to alpha
|
||||||
|
env:
|
||||||
|
ALPHA_SSH_KEY: ${{ secrets.ALPHA_SSH_KEY }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
|
echo "$ALPHA_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
ssh-keyscan alpha.mintel.me >> ~/.ssh/known_hosts
|
ssh -o StrictHostKeyChecking=no deploy@alpha.mintel.me \
|
||||||
|
"cd /opt/alpha/sites/mb-grid-solutions && docker compose pull && docker compose up -d"
|
||||||
- name: Deploy on Alpha
|
|
||||||
run: |
|
|
||||||
ssh deploy@alpha.mintel.me "
|
|
||||||
cd /opt/alpha/sites/mb-grid-solutions &&
|
|
||||||
docker compose pull &&
|
|
||||||
docker compose up -d
|
|
||||||
"
|
|
||||||
Reference in New Issue
Block a user