-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a51836
commit 5128bbf
Showing
3 changed files
with
116 additions
and
82 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Deploy Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
repository_dispatch: | ||
types: [trigger_deployment] | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/dulliag/dulli-bot | ||
|
||
jobs: | ||
renew_docker_compose: | ||
name: Rebuild Remote Docker-Compose | ||
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- name: Connect and deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.RS1_HOST }} | ||
username: ${{ secrets.RS1_USER }} | ||
password: ${{ secrets.RS1_PASSWORD }} | ||
port: 22 | ||
script: | | ||
echo ${{ secrets.NPM_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin | ||
CONTAINER_NAME="dullibot" | ||
if [ "$(docker ps -a --filter "name=$CONTAINER_NAME" --format '{{.Names}}')" ]; then | ||
docker container stop $CONTAINER_NAME | ||
docker container rm -f $CONTAINER_NAME | ||
fi | ||
if [ "$(docker images -q "${{ env.IMAGE_NAME }}:latest")" ]; then | ||
docker rmi "${{ env.IMAGE_NAME }}:latest" | ||
fi | ||
docker pull ${{ env.IMAGE_NAME }}:latest | ||
docker run -itd --env-file '${{ secrets.RS1_REMOTE_LOCATION }}/dullibot.env' --restart on-failure:3 --name=$CONTAINER_NAME ${{ env.IMAGE_NAME }}:latest |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Build & Publish Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/dulliag/dulli-bot | ||
|
||
jobs: | ||
build_image: | ||
name: Build Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build Image | ||
run: | | ||
rm .npmrc | ||
echo $'@kleithor:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken='$NPM_TOKEN >> .npmrc | ||
docker build --secret id=npm,src=.npmrc . -t ${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
mkdir -p artifacts | ||
docker save ${{ env.IMAGE_NAME }}:${{ github.ref_name }} > artifacts/docker-image.tar | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Save Image | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: docker-artifact | ||
path: artifacts | ||
retention-days: 1 | ||
|
||
push_image: | ||
needs: build_image | ||
name: Push Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Retrieve Docker Image | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker-artifact | ||
path: artifacts | ||
|
||
- name: Load Image | ||
run: | | ||
cd artifacts | ||
docker load < docker-image.tar | ||
- name: Login | ||
run: | | ||
echo ${{ secrets.NPM_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin | ||
- name: Push Image | ||
run: | | ||
docker push ${{ env.IMAGE_NAME }}:${{ github.ref_name }} | ||
docker tag ${{ env.IMAGE_NAME }}:${{ github.ref_name }} ${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.IMAGE_NAME }}:latest | ||
trigger_deployment: | ||
needs: push_image | ||
name: Trigger deployment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dispatch | ||
uses: peter-evans/repository-dispatch@v2 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
event-type: trigger_deployment | ||
|
||
cleanup: | ||
needs: push_image | ||
name: Cleanup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete Artifact | ||
uses: geekyeggo/delete-artifact@v1 | ||
with: | ||
name: docker-artifact |