-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from badging:api-fixes
fixed deployment configs
- Loading branch information
Showing
1 changed file
with
12 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
pull_request: | ||
|
||
env: | ||
REGISTRY: "registry.digitalocean.com/project-badging" | ||
REGISTRY: "registry.digitalocean.com/badging" | ||
IMAGE_NAME: "badging" | ||
|
||
jobs: | ||
|
@@ -20,7 +20,7 @@ jobs: | |
- name: Lint code | ||
run: npm run format | ||
|
||
docker-build: | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
|
@@ -38,23 +38,10 @@ jobs: | |
while read -r image_tag; do | ||
doctl registry image delete $REGISTRY/$IMAGE_NAME:$image_tag; | ||
done | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
- name: Build Docker image | ||
run: docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} . | ||
|
||
deploy: | ||
needs: docker-build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
steps: | ||
- name: Login to DigitalOcean registry | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
- name: Stop and remove existing images with the same name on the droplet | ||
- name: Push Docker image to DigitalOcean Droplet | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
|
@@ -65,18 +52,11 @@ jobs: | |
docker stop ${{ env.IMAGE_NAME }} | ||
docker rm ${{ env.IMAGE_NAME }} | ||
fi | ||
- name: Deploy Docker image to DigitalOcean Droplet | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
echo ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} || true | ||
docker load -i - << '${{ runner.workspace }}/.image.tar' | ||
docker run -d \ | ||
-p ${{ secrets.PORT }}:${{ secrets.PORT }} \ | ||
--env-file /home/${{ secrets.USERNAME }}/.env \ | ||
--restart=always \ | ||
--name ${{ env.IMAGE_NAME }} \ | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
-p ${{ secrets.PORT }}:${{ secrets.PORT }} \ | ||
--env-file /home/${{ secrets.USERNAME }}/.env \ | ||
--restart=always \ | ||
--name ${{ env.IMAGE_NAME }} \ | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} |