Update persistence.xml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
env: | |
IMAGE_NAME: ${{ github.event.repository.name }} | |
SSH_HOST: ${{ secrets.SSH_HOST }} | |
SSH_USER: ${{ secrets.SSH_USER }} | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
DB_USER_NAME: ${{ secrets.DB_USER_NAME }} # Add here environment variables first and then when reference it when you build the docker image | |
DB_USER_PASSWORD: ${{ secrets.DB_USER_PASSWORD }} # Add here environment variables first and then when reference it when you build the docker image | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: lower-repo | |
name: Repository to lowercase | |
run: | | |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
- name: Build & push docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 # Specify the platforms you need | |
tags: ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest | |
file: Dockerfile # Adjust if your Dockerfile is not in the root directory | |
build-args: | | |
DB_USER_NAME=${{ env.DB_USER_NAME }} | |
DB_USER_PASSWORD=${{ env.DB_USER_PASSWORD }} | |
#Add here your environment Variables which you implemented above | |
- name: Image digest | |
run: echo ${{ steps.build-and-push.outputs.digest }} | |
- name: Pull image and start container | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ env.SSH_HOST }} | |
username: ${{ env.SSH_USER }} | |
key: ${{ env.SSH_PRIVATE_KEY }} | |
script: | | |
docker container rm -f ${{ env.IMAGE_NAME }} 2> /dev/null || true | |
docker image rm ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest 2> /dev/null || true | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
docker pull ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest | |
docker run -d -p 8080:8080 --name ${{ env.IMAGE_NAME }} ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest | |
# Explainaition for the last line: | |
# docker run -d -p [externalPort]:[internalPort] --name [imageName] ghcr.io/[repositoryOwner]/[repositoryName]:latest |