Skip to content

Commit a678414

Browse files
committed
gh - portainer - use shared deployment solution;
1 parent 1685de1 commit a678414

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pages Deploy
1+
name: Pages
22

33
on:
44
workflow_dispatch:
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: Portainer Deploy
1+
name: Portainer Stack
2+
run-name: Portainer ${{ github.sha }}
23

34
on:
4-
workflow_dispatch: # allows the workflow to be triggered manually
5+
workflow_dispatch:
56

67
env:
78
DOCKER_STACK_NAME: portainer
89
ACTION_RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
910

1011
jobs:
1112
deploy:
12-
name: Update Deployment
1313
runs-on: ubuntu-latest
1414
if: ${{ github.run_attempt == 1 }}
1515

@@ -37,8 +37,7 @@ jobs:
3737
#### docker stack deploy
3838
set -x
3939
40-
# cleanup previous deployment id (fixes incorrect stop by previous re-run)
41-
ssh $SSH_TARGET rm -f portainer_deployment_id.txt
40+
clean_deployment_id ${{ env.DOCKER_STACK_NAME }}
4241
4342
export DATA_ROOT="/home/${{ secrets.REMOTE_USER }}"
4443
export SERVER_NAME=${{ secrets.REMOTE_HOST }}
@@ -48,8 +47,7 @@ jobs:
4847
-c deploy/portainer/portainer-agent-stack.yml \
4948
${{ env.DOCKER_STACK_NAME }}
5049
51-
# store deployment id allowing to make status inactive on stop
52-
ssh $SSH_TARGET sh -c "'echo $DEPLOYMENT_ID > portainer_deployment_id.txt'"
50+
save_deployment_id ${{ env.DOCKER_STACK_NAME }}
5351
5452
- uses: ./.github/composites/deploy-status
5553
if: always()
@@ -58,11 +56,10 @@ jobs:
5856
state: ${{ job.status }}
5957

6058
stop:
61-
name: Stop Deployment
6259
runs-on: ubuntu-latest
6360
if: ${{ github.run_attempt > 1 }}
6461
permissions:
65-
deployments: write # update deployment status
62+
deployments: write
6663

6764
steps:
6865
- uses: actions/checkout@v4
@@ -77,16 +74,11 @@ jobs:
7774
step_run: |
7875
#### stop deployment
7976
set -x # debug
80-
81-
# obtain deployment id to make status inactive
82-
DEPLOYMENT_ID=$(ssh $SSH_TARGET "cat portainer_deployment_id.txt")
83-
echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_ENV
84-
85-
# undeploy existing stack
77+
load_deployment_id ${{ env.DOCKER_STACK_NAME }}
8678
docker stack rm ${{ env.DOCKER_STACK_NAME }}
8779
8880
- name: Deployment Status (inactive)
8981
uses: ./.github/composites/deploy-status
9082
with:
9183
token: ${{ secrets.GITHUB_TOKEN }}
92-
state: inactive
84+
state: 'inactive'

0 commit comments

Comments
 (0)