-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
169 lines (168 loc) · 6.09 KB
/
index.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://unpkg.com/nes.css/css/nes.css" rel="stylesheet" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap"
rel="stylesheet"
/>
<style>
html,
body,
pre,
code,
kbd,
samp {
font-family: "Press Start 2P";
}
code {
color: green;
background-color: black;
}
</style>
</head>
<body>
<div style="padding: 50px; justify-content: center">
<div style="width: 90%; padding: 10px; color: orange; background: grey">
<p style="font-size: 40px"><i class="nes-icon coin is-large"></i></i>ppgaver</p>
</div>
<div style="width: 90%; padding: 10px; color: black; background: orange">
<div style="margin-left: 60px;margin-right: 10px;">
<div class="nes-balloon from-left" style="width: 100%;">
<h2>Oppgave 1</h2>
<p>Hent Github pages prosjektet ditt til Raspberry Pi.</p>
<p>
<i>a)</i><br />
Lag et nytt par med ssh-nøkler uten passord på Raspberry Pi.
<a
href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"
>Se her</a
>
</p>
<p>
<i>b)</i><br />
Legg til ny public ssh-nøkkel til i Github som deploy key i ditt pages
prosjekt.
<a
href="https://dylancastillo.co/how-to-use-github-deploy-keys/#create-a-deploy-key-on-github"
>Se her</a
>
</p>
<p>
<i>c)</i><br />
Sjekk om du har installert git på Raspberry Pi. Hvis ikke:
<code>apt install git</code>
</p>
<p>
<i>d)</i><br />
På Raspberry Pi, slett default side i Nginx
<code>rm /var/www/html/*.html</code> (Sjekk først om den ligger der).
Hente side fra Github
<code>git clone [email protected]:example/example.github.io.git .</code>
Husk å stå i katalogen <code>/var/www/html</code>
</p>
<hr />
<p>
<i class="snes-logo"></i>Husk pause!!!
</p>
</div>
</div>
<i class="nes-mario"></i>
<div style="margin-left: 10px;margin-right: 60px;">
<div class="nes-balloon from-right" style="width: 100%">
<h2>Oppgave 2</h2>
<p>
Lag et SSL fra <a href="https://letsencrypt.org/">Let's Encrypt</a>.
Legg til sertifikat til webserveren din, slik at du kan bruke HTTPS.
</p>
<p>
<i>a)</i><br />
Installer <a href="https://certbot.eff.org/">Certbot</a> og
Nginx-plugin på Raspberry Pi.
<code>apt install certbot python3-certbot-nginx</code>
</p>
<p>
<i>b)</i><br />
Lag et sertifikat ved hjelp av Certbot.
<code>certbot --nginx -d eksempel.kantega.no</code>
</p>
<hr />
<p>
<i class="nes-logo"></i>Husk pause!!!
</p>
</div>
</div>
<div style="float:right">
<i class="nes-kirby"></i>
</div>
<div style="margin-left: 60px;margin-right: 10px;">
<div class="nes-balloon from-left" style="width: 100%;">
<h2>Oppgave 3</h2>
<p>
Automatiser publisering av endringer på siden med
<a href="https://github.com/features/actions">Github Actions</a><i class="nes-octocat animate"></i>
</p>
<p>
<i>a)</i><br />
Legg public key du lagde tidligere inn i <code>.ssh/authorized_keys</code> på Raspberry.
</p>
<p>
<i>b)</i><br />
Vi vil at Github Actions skal kopiere koden vår til Raspberry når vi
gjør en push. Vi skal bruke et ferdiglaget prosjekt sammen med Github
Actions. Se litt på eksemplene
<a href="https://github.com/appleboy/ssh-action">her</a>. Før må vi
legge inn litt info i prosjektet om hvor prosjektet skal lastes opp. Gå
til <code>Settings > Secrets and variables > Actions</code> i ditt Github-prosjekt og
legg inn:
<div class="lists">
<ul class="nes-list is-disc">
<li>HOST=DNS navn på Raspberry</li>
<li>KEY=Privat nøkkel opprettet tidligere</li>
<li>PORT=SSH port (22)</li>
<li>USERNAME=Brukernavn (root)</li>
</ul>
</div>
</p>
<p>
<i>c)</i><br />
I ditt prosjekt opprett filen <code>.github/workflows/github-actions.yml</code> med innholdet:
<pre style="font-size: 10px;background-color: black;color: green;">
name: remote ssh command
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /var/www/html
git pull
</pre>
Merk den siste biten under <code>script:</code> i filen.
</p>
<p>
<i>d)</i><br />
Gjør en endring i koden og push, sjekk om den virker under Actions i prosjektet.
</p>
<hr/>
<p>
<i class="nes-icon trophy is-large"></i>Godt jobba!!!<i class="nes-icon trophy is-large"></i><br/>
Har du husket is?
</p>
</div>
</div>
<i class="nes-ash"></i>
</div>
</div>
</body>
</html>