Skip to content

Change username to deploytest #43

Change username to deploytest

Change username to deploytest #43

Workflow file for this run

name: Deploy to Server
on:
push:
branches:
- deploytest
permissions:
packages: write
jobs:
commit-hash:
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.get_commit.outputs.commit_hash }}
steps:
- uses: actions/checkout@v4
- name: Get commit hash
id: get_commit
run: echo "::set-output name=commit_hash::$(git rev-parse HEAD)"
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:
needs:
- build-and-test
- commit-hash
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:${{ needs.commit-hash.outputs.commit_hash }}
deploy:
runs-on: ubuntu-latest
needs:
- build-and-push-image
- commit-hash
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: create env file
run: |
echo "GIT_COMMIT_HASH=${{ github.sha }}" >> env
- name: 'Docker Stack Deploy'
uses: cssnr/stack-deploy-action@v1
with:
name: 'guestbook'
file: 'stack.yaml'
host: zenful.cloud
user: deploytest
ssh_key: ${{ secrets.DEPLOY_SSH_KEY }}
env_file: './env'