-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Toniolo-Marco/organization-and-roles
Organization and roles
- Loading branch information
Showing
10 changed files
with
222 additions
and
48 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,51 @@ | ||
name: Build & Release | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
paths: | ||
- "src/**" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Build_And_Release: | ||
runs-on: [self-hosted, typst] | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Compile LaTeX document | ||
id: compile | ||
shell: bash | ||
run: | | ||
# compile the main file | ||
typst compile --root=./ --font-path=./src/fonts/segoe-ui-this src/main.typ git-for-dummies.pdf | ||
- name: Delete previous release | ||
id: deletePreviuosRelease | ||
if: steps.compile.outcome == 'success' | ||
continue-on-error: true | ||
shell: bash | ||
run: | | ||
# Get the latest release ID | ||
LATEST_RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.id') | ||
# Delete the latest release | ||
if [ "$LATEST_RELEASE_ID" != "null" ]; then | ||
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/$LATEST_RELEASE_ID" | ||
else | ||
echo "No previous release found." | ||
fi | ||
- name: Publish Release | ||
id: release | ||
if: steps.compile.outcome == 'success' | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ github.workspace }}/git-for-dummies.pdf | ||
asset_name: Git-for-Dummies.pdf | ||
overwrite: true | ||
body: "Brief introduction to using git, GitHub and managing an organization for Professor Patrignani's Advanced Programming course" | ||
release_name: "Git for Dummies" |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
# Use GitHub Actions Runner as the base image | ||
FROM debian:stable-slim | ||
|
||
ADD ./runner runner | ||
|
||
WORKDIR /runner | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
SHELL ["bash", "-c"] | ||
|
||
RUN ./bin/installdependencies.sh && apt-get install -y xz-utils jq curl && apt-get autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
# Install Typst | ||
RUN curl -L https://github.com/typst/typst/releases/latest/download/typst-x86_64-unknown-linux-musl.tar.xz -o typst.tar.xz \ | ||
&& tar -xf typst.tar.xz \ | ||
&& mv typst-x86_64-unknown-linux-musl/typst /usr/local/bin/ \ | ||
&& rm -rf typst.tar.xz typst-x86_64-unknown-linux-musl | ||
|
||
# Verify Typst installation | ||
RUN typst --version | ||
|
||
ADD --chmod=754 ./start.sh start.sh | ||
|
||
ENTRYPOINT ["bash", "-c", "./start.sh"] | ||
|
||
ENV RUNNER_MANAGER_TOKEN="" | ||
ENV RUNNER_NAME="" | ||
ENV REPO_NAME="" | ||
ENV REPO_OWNER="" | ||
ENV ACTIONS_RUNNER_INPUT_REPLACE=true | ||
ENV RUNNER_ALLOW_RUNASROOT=true |
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,34 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME="typst-runner:latest" | ||
|
||
case $(uname -m) in | ||
x86_64) | ||
ARCH="x64" | ||
;; | ||
aarch64) | ||
ARCH="arm64" | ||
;; | ||
*) | ||
echo "Unsupported architecture" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo "retrieving latest version number from release page" | ||
LATEST=`curl -s -i https://github.com/actions/runner/releases/latest | grep location:` | ||
LATEST=`echo $LATEST | sed 's#.*tag/v##'` | ||
LATEST=`echo $LATEST | sed 's/\r//'` | ||
echo "downloading latest GitHub runner (${LATEST})" | ||
|
||
curl --progress-bar -L "https://github.com/actions/runner/releases/download/v${LATEST}/actions-runner-linux-${ARCH}-${LATEST}.tar.gz" -o runner.tgz | ||
|
||
mkdir -p runner | ||
|
||
echo "unpacking runner.tgz" | ||
tar -zxf runner.tgz -C runner | ||
|
||
docker build -t ${IMAGE_NAME} . | ||
|
||
echo "cleaning" | ||
rm -rf runner runner.tgz |
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,14 @@ | ||
services: | ||
typst-runner: | ||
image: typst-runner:latest | ||
container_name: typst-runner | ||
restart: always | ||
labels: | ||
- "com.centurylinklabs.watchtower.enable=false" | ||
volumes: | ||
- /etc/localtime:/etc/localtime:ro | ||
environment: | ||
- RUNNER_MANAGER_TOKEN= | ||
- RUNNER_NAME=typst-runner | ||
- REPO_OWNER=Toniolo-Marco | ||
- REPO_NAME=git-for-dummies |
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,31 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
: $REPO_NAME | ||
: $REPO_OWNER | ||
: $RUNNER_MANAGER_TOKEN | ||
: $RUNNER_NAME | ||
|
||
# fetch a short-lived runner registration token for the org | ||
reg_token=$(curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $RUNNER_MANAGER_TOKEN" \ | ||
https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runners/registration-token | jq -r .token) | ||
|
||
/bin/bash config.sh --unattended --url https://github.com/${REPO_OWNER}/${REPO_NAME} --name ${RUNNER_NAME} --work _work --token ${reg_token} --labels typst,self-hosted | ||
|
||
remove () { | ||
local rem_token=$(curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $RUNNER_MANAGER_TOKEN" \ | ||
https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runners/remove-token | jq -r .token) | ||
|
||
./config.sh remove --token $rem_token | ||
} | ||
|
||
trap remove EXIT | ||
|
||
./bin/runsvc.sh |
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
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 |
---|---|---|
@@ -1,5 +1,43 @@ | ||
= Organization | ||
|
||
L'organizzazione è un'account condiviso da più utenti dove è possibile collaborare su uno o più progetti, definendo ruoli e funzioni. | ||
Utilizzando le organizzazioni è possibile creare una suddivisione che rispecchia quella in classe, dove il *Working group coordinator* ha tutti i permessi | ||
i *Git Maintainer* possono creare, modificare, accettare, rifiutare le pull request e scrivere ed eseguire delle Actions (di cui parleremo più avanti). | ||
i *Git Maintainer* possono creare, modificare, accettare, rifiutare le pull request e scrivere ed eseguire delle Actions (di cui parleremo più avanti) e tutti gli altri possono aprire issue, fare fork e creare delle pull request. | ||
|
||
== Creare un'organizzazione | ||
Per creare un'organizzazione recatevi sulla homepage di GitHub dopo aver fatto il login col vostro account, cliccate sul vostro nome utente (vicino alla foto) nell'angolo in alto a sinistra, e poi su crea organizzazione. Vi si aprirà la pagina coi piani, selezionate quello gratuito, poi compilate il form con i dettagli prestando attenzione a selezionare che l'organizzazione appartiene al vostro account personale e non ad un'azienda. | ||
|
||
== Creare i gruppi | ||
GitHub per gestire i permessi nelle organizzazioni fa uso dei gruppi, un gruppo è un insieme di utenti, ad ogni gruppo sono associati dei permessi, gli utenti di un gruppo ereditano i permessi. | ||
Per creare i gtuppi, cambiate dal vostro account a quello dell'organizzazione, se non lo avete già fatto, cliccando sempre sul vostro nome e selezionando quello dell'organizzazione, poi spostatevi su *Teams*, e create i seguenti gruppi: | ||
|
||
- Organization Owners | ||
- Members | ||
- Tutors | ||
|
||
=== Organization Owners | ||
Composto dal Working group coordinator e dai Git Maintainers, questo gruppo *deve avere tutti i permessi*, i membri di questo gruppo devono essere manualmente | ||
impostati come Owners dell'organizzazione andando su *people*, cliccando sui *tre pallini* e poi su *cambia ruolo* e in fine *owner*. In questo modo, avranno pieni poteri su tutta l'organizzazione. | ||
|
||
=== Members | ||
Questo gruppo, deve poter forkare, creare issue e pull request sul repository del common crate, il ruolo da associarvi è Triage ma solo sul singolo repository | ||
dopo vi spiegheremo come fare, per ora create il gruppo e non aggiungete membri, visto che sarete in \~100/150 persone è impensabile che qualcuno aggiunaga manualmente tutti i partecipanti, per questo si userà l'inviter, come spiegato successivamente. | ||
|
||
=== Tutors | ||
Questo gruppo avrà acesso in lettura al repository, conterra i tutors i quali andranno aggiunti manualmente in base al loro interesse, alcuni vi chiederanno di entrare e altri invece no, anche qui, il i permessi del gruppo vanno impostati sul singolo repository. | ||
|
||
== Il repository | ||
Create adesso il repository contenente il codice del Common Crate, come visibilità mettete private (il professore vi spiegherà che è per evitare che i futuri studenti trovino tutto pronto), le altre opzioni sceglietele in base | ||
alle vostre preferenze. Una volta creato andate in *impostazioni*, poi *collaboratori e teams* e cliccate *aggiungi teams*, cercate *Organization Owners* e come ruolo assegnategli *Admin*. Ripetete per i *Members* e come ruolo | ||
scegliete *Triage*, per ultimo il gruppo *Tutors* ai quali va il ruolo di *Read*. | ||
|
||
== Workflow consigliato | ||
Lo scorso anno, abbiamo provato a mimare l'approccio utilizzato dai grandi progetti open source per la gestione dei repository, questo cosisteva nelle seguenti fasi | ||
+ Apertura di una issue | ||
+ Votazione (se si tratta di una feature proposta) | ||
+ Fork del repository | ||
+ implentazione | ||
+ Apertura di una pull request associata alla issue | ||
+ Revisione | ||
+ Merge nel main | ||
+ Pubblicazione della nuova versione | ||
|
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