Skip to content

fix the deployments #37

fix the deployments

fix the deployments #37

Workflow file for this run

name: Deploy to Server
on:
push:
branches:
- deploytest
permissions:
packages: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ghcr.io/dreamsofcode-io/guestbook:$COMMIT_SHORT_SHA
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Add host
run: |
ssh-keyscan zenful.cloud > ~/.ssh/known_hosts
- name: Set up Docker Compose
run: |
# Install Docker Compose
curl -L "https://github.com/docker/compose/releases/download/v2.19.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- name: Copy over password
run: |
ssh [email protected] "echo ${{ secrets.DB_PASSWORD }} > /home/deploytest/db-password.txt"
- name: Run Docker Compose
run: |
export GIT_COMMIT_HASH=$COMMIT_SHORT_SHA
export DB_PASSWORD_PATH="/home/deploytest/db-password.txt"
export DOCKER_HOST=ssh://[email protected]
docker-compose -f ./compose.prod.yaml up -d