Skip to content

Commit

Permalink
added mirror workflow gitlab, removed VPS deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenaH84 committed May 16, 2024
1 parent 4e1ecbd commit c32dba5
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ on:
- main

env:
SSH_USER: lhendrix
SSH_HOST: 51.68.188.78
REGISTRY: ghcr.io
IMAGE_NAME: battmoteam/battmogui:latest
WORKDIR: battmogui
GITLAB_URL: https://gitlab.sintef.no/FFP-products/prod/webapp-instances/102023526-1006.git

jobs:
publish:
name: publish image
name: publish docker images
runs-on: ubuntu-latest

steps:
Expand All @@ -30,25 +29,17 @@ jobs:
- name: Publish
run: docker-compose -f docker-compose-deploy.yml push

deploy:
name: Deploy image
mirror:
name: mirror repository to GitLab
runs-on: ubuntu-latest
needs: publish

steps:
- name: Install SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.ACTIONS_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Test SSH Connection
run: ssh -o StrictHostKeyChecking=no ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "echo SSH connection successful"
- name: Login to Registry
run: echo ${{ secrets.PAT }} | docker login ghcr.io -u lorenah84 --password-stdin
- name: Pull and Run Containers
run: |
ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "cd ${{ env.WORKDIR }} && \
docker compose -f docker-compose.yml pull && \
docker compose -f docker-compose.yml up -d"
- name: Cleanup
run: rm -rf ~/.ssh
- name: Checkout code
uses: actions/checkout@v2

- name: Mirror changes
env:
GITLAB_PAT: ${{ secrets.GITLAB_PAT }}
run: |
git remote add gitlab ${{ env.GITLAB_URL }}
git fetch origin
git push --mirror gitlab

0 comments on commit c32dba5

Please sign in to comment.