Replaced env with vars
Some checks failed
Build Docker Image and Deploy / Build Image and push to Registry (push) Successful in 5m42s
Build Docker Image and Deploy / Deploy on webserver (push) Failing after 10s

This commit is contained in:
Cyril Šebek 2024-07-07 21:14:28 +02:00
parent 8bd64f03c8
commit abbb4a26ac
Signed by: blboun3
SSH Key Fingerprint: SHA256:n9dMtOPzgsD+CCerUJslEnU2dzVanbaIv0XDQVRVjeg

View File

@ -28,7 +28,7 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
@ -37,7 +37,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ vars.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the docker/build-push-action action to build the image, based on your repository's Dockerfile. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the context parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the docker/build-push-action repository.
@ -62,14 +62,14 @@ jobs:
ssh-private-key: ${{ secrets.SSH_PRIV_KEY }}
- name: Login to registry
run: ssh ${{ env.TARGET_USER }}@${{ env.TARGET }} "docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ env.REGISTRY }}"
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} "docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ vars.REGISTRY }}"
- name: Pull new image
run: ssh ${{ env.TARGET_USER }}@{{ env.TARGET }} "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
run: ssh ${{ vars.TARGET_USER }}@{{ vars.TARGET }} "docker pull ${{ vars.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
- name: Logout from registry
run: ssh ${{ env.TARGET_USER }}@{{ env.TARGET }} "docker logout ${{ env.REGISTRY }}"
run: ssh ${{ vars.TARGET_USER }}@{{ vars.TARGET }} "docker logout ${{ vars.REGISTRY }}"
- name: Stop and Remove the container
run: ssh ${{ env.TARGET_USER }}@{{ env.TARGET }} "docker stop ${{ env.IMAGE_NAME }} && docker remove ${{ env.IMAGE_NAME }}"
run: ssh ${{ vars.TARGET_USER }}@{{ vars.TARGET }} "docker stop ${{ env.IMAGE_NAME }} && docker remove ${{ env.IMAGE_NAME }}"
- name: Recreate the container
run: ssh ${{ env.TARGET_USER }}@{{ env.TARGET }} "docker run --name=${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}:latest"
run: ssh ${{ vars.TARGET_USER }}@{{ vars.TARGET }} "docker run --name=${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}:latest"
- name: Clean old images
run: ssh ${{ env.TARGET_USER }}@{{ env.TARGET }} "docker image prune -a"
run: ssh ${{ vars.TARGET_USER }}@{{ vars.TARGET }} "docker image prune -a"