Skip to content

Commit

Permalink
misc(ci/cd): Pull the images in server
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzuan committed Nov 4, 2024
1 parent cfd0658 commit 900676e
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
- name: Settle up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Github Container Registry
- name: Authenticating to Eden Server realms.
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SERVER_PRIVATE_KEY }}

- name: Authenticating to GHCR realms
run: echo "${{ secrets.GH_TOKEN }}" | docker login -u "${{ github.actor }}" ghcr.io --password-stdin

- name: Build Docker image
- name: Treaty Build the Docker image
run: |
docker build \
--build-arg PORT=3121 \
Expand All @@ -43,12 +48,30 @@ jobs:
--build-arg CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} \
-t ghcr.io/xyzuan/xyzuan_api_v2:dev -f misc/Dockerfile.dev .
- name: Tag Docker image
- name: Adding tags to the Images
run: |
IMAGE_NAME=ghcr.io/xyzuan/xyzuan_api_v2
docker tag $IMAGE_NAME:dev $IMAGE_NAME:$(echo "${{ github.sha }}" | head -c 7)
- name: Push Docker image
- name: Bring the Images to GHCR
run: |
docker push ghcr.io/xyzuan/xyzuan_api_v2:dev
docker push ghcr.io/xyzuan/xyzuan_api_v2:$(echo "${{ github.sha }}" | head -c 7)
- name: Serving the Images in Eden Server realms.
run: |
ssh-keyscan -t rsa ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
ssh ${{ github.actor }}@${{ secrets.SERVER_HOST }} << 'EOF'
echo 'Authenticating to GHCR realms...'
echo "${{ secrets.GH_TOKEN }}" | docker login -u "${{ github.actor }}" ghcr.io --password-stdin
echo 'Pulling the latest image from GHCR...'
docker pull ghcr.io/xyzuan/xyzuan_api_v2:dev
echo 'Force Blowing the exist Docker Container...'
docker rm -f xyzuan-api-v2-dev
echo 'Running the Docker Container...'
docker run -d -p 61131:3121 --name xyzuan-api-v2-dev ghcr.io/xyzuan/xyzuan_api_v2:dev
EOF

0 comments on commit 900676e

Please sign in to comment.