-
-
Notifications
You must be signed in to change notification settings - Fork 10
119 lines (109 loc) · 4.4 KB
/
deploy.yml
File metadata and controls
119 lines (109 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Deploy
on:
workflow_dispatch:
inputs:
version:
description: "The version of the website to deploy"
type: string
required: true
push_image:
description: "Push to remote. Disable to use an already pushed image with the same version"
type: boolean
default: true
deploy_image:
description: "Deploy the image using this version to the server"
type: boolean
default: true
send_webhook:
description: "Send a webhook message in the #website channel after deployment"
type: boolean
default: true
run_linting:
description: "Run the linting scripts on the documentation"
type: boolean
default: true
jobs:
build:
name: Build image
runs-on: ubuntu-latest
outputs:
docker_digest: ${{ steps.docker.outputs.digest }}
strategy:
matrix:
# Set the same version as in Dockerfile
node: [22]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node.js v${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install dependencies
run: npm ci
# Run lint and build first to make sure the site will still build
# since workflow dispatch can be run on failed builds
- name: Run eslint
run: npm run lint
if: inputs.run_linting
- name: Run markdown lint
run: npm run lint-markdown
if: inputs.run_linting
- name: Run file lint
run: npm run lint-files
if: inputs.run_linting
- name: Check guide build
run: npm run docs:build
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
id: docker
with:
context: .
push: ${{ github.event.inputs.push_image }}
# See https://github.com/docker/build-push-action/issues/535#issuecomment-1936723515
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_IMAGE_NAME }}:${{ github.event.inputs.version }}
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
if: github.event.inputs.deploy_image
steps:
- run: |
echo "Updating the website to version ${{ github.event.inputs.version }}!"
- name: Login and redeploy
# Do not use @master because of https://github.com/appleboy/ssh-action/issues/317
uses: appleboy/ssh-action@v1.0.3
id: ssh
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
# Not using deployment/move_dummyassets.sh for now
# If that file ever changes, also update the file on the server
script: |
sh /home/${{ secrets.RLMM_USERNAME }}/web_repo/deployment/update_and_deploy.sh ${{ github.event.inputs.version }}
sh /home/${{ secrets.RLMM_USERNAME }}/move_dummyassets.sh
- name: Send webhook result
if: github.event.inputs.send_webhook
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: GitHub
avatar-url: ${{ vars.DISCORD_WEBHOOK_AVATAR }}
embed-color: 5793266
embed-author-name: ${{ github.actor }}
embed-author-icon-url: https://avatars.githubusercontent.com/u/${{ github.actor_id }}
embed-title: '[${{ github.repository_owner }}]: Deploy workflow triggered'
embed-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# Deployed url will for now always be the same as this workflow works only for the website
embed-description: |-
Version: [`${{ github.event.inputs.version }}`](https://hub.docker.com/layers/${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_IMAGE_NAME }}/${{ github.event.inputs.version }}/images/${{ needs.build.outputs.docker_digest }})
Status: ${{ steps.ssh.conclusion }}
Deployed on: [${{ github.ref_name }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
Deployed url: [rocketleaguemapmaking.com](https://rocketleaguemapmaking.com/)