Skip to content

Commit

Permalink
fix/restart-server (#104)
Browse files Browse the repository at this point in the history
(hopefully)
  • Loading branch information
nicopico-dev authored Aug 27, 2024
1 parent b626e96 commit 93d354e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/deploy-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
server-dir: ${{ vars.FTP_DIR }}
local-dir: ./deploy/
create-github-release:
if: ${{ !env.ACT }}
needs: deploy
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -71,7 +72,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Trigger Restart Server workflow
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: trigger-restart-server
uses: ./.github/workflows/restart-server.yml
secrets: inherit
9 changes: 4 additions & 5 deletions .github/workflows/restart-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Restart Server

on:
workflow_dispatch: # Allows manual triggering
repository_dispatch:
types: [ trigger-restart-server ]
workflow_call: # Allows calling from another workflow

jobs:
restart-server:
Expand All @@ -18,12 +17,12 @@ jobs:
{
"X-Secret-Key": "${{ secrets.SERVER_MAINTENANCE_SECRET_KEY }}"
}
preventFailureOnNoResponse: true
- name: Wait for 1 minutes
- name: Wait until the server has stopped
run: |
sleep 60
sleep 15
- name: Restart Server
uses: fjogeleit/http-request-action@v1
with:
url: ${{ vars.SERVER_ENDPOINT }}
method: GET
preventFailureOnNoResponse: true
2 changes: 1 addition & 1 deletion act/n2rss_dev.variables
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FTP_DIR=/n2rss/
SERVER_ENDPOINT=http://localhost:8080
SERVER_ENDPOINT=http://host.docker.internal:8080
7 changes: 6 additions & 1 deletion test_cd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
# DEALINGS IN THE SOFTWARE.
#

act push -s GITHUB_TOKEN="$(gh auth token)" \
echo "{ \"ref\": \"refs/tags/1.0.0\" }" > act_cd_event.json

act push -e act_cd_event.json \
-s GITHUB_TOKEN="$(gh auth token)" \
--container-architecture linux/amd64 \
--artifact-server-path ./act/artifacts \
--var-file ./act/n2rss_dev.variables \
--secret-file ./act/n2rss_dev.secrets

rm act_cd_event.json
25 changes: 25 additions & 0 deletions test_restart_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2024 Nicolas PICON
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#

act workflow_dispatch \
-W .github/workflows/restart-server.yml \
-s GITHUB_TOKEN="$(gh auth token)" \
--container-architecture linux/amd64 \
--artifact-server-path ./act/artifacts \
--var-file ./act/n2rss_dev.variables \
--secret-file ./act/n2rss_dev.secrets

0 comments on commit 93d354e

Please sign in to comment.