forked from mathialm/secfit
-
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
Showing
1 changed file
with
36 additions
and
0 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,36 @@ | ||
| name: Deploy Docker on Code Update | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build_and_deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v1 | ||
|
|
||
| - name: SSH into server and build/deploy Docker | ||
| run: | | ||
| # SSH into your server, build the images, and deploy them | ||
| ssh jifollan@tdt4242-04.idi.ntnu.no << 'EOF' | ||
| cd secfit | ||
| git pull | ||
| # Stop and remove old containers | ||
| docker-compose down | ||
| # Build the Docker images (only rebuild if necessary) | ||
| docker-compose build | ||
| # Run the containers in detached mode | ||
| docker-compose up -d | ||
| EOF | ||
| env: | ||
| SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} # You need to add your private key to GitHub Secrets | ||
|
|