You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# How to connect GitHub to a PNNL GitLab (push) Mirror
2
+
3
+
To run on our HPC clusters at PNNL while hosting our code base on GitHub, we utilize PNNL's CI/CD services on GitLab.
4
+
5
+
With GitLab premium, integration between GitHub and GitLab is included. The tier of GitLab that we have does not and did not initially support this. While switching to premium would alleviate some of the burden here, our technical requirements expanded having to test on more than one cluster. This is how we have architected a solution with the base level GitLab offering.
6
+
7
+
The PNNL GitLab repository is a push mirror of the GitHub. So whenever a commit is pushed to a pull request or the `main` branch - the changes are pushed to the GitLab and a CI pipeline is triggered.
8
+
9
+
## Steps in linking the GitLab and GitHub
10
+
11
+
1. Push mirror & pipeline trigger
12
+
13
+
In [`pnnl_mirror.yaml`](/.github/workflows/pnnl_mirror.yaml), we use the variables `GIT_USER`, `GIT_PASSWORD`, and `PNNL_PIPELINE_TRIGGER`. `GIT_PASSWORD` and `PNNL_PIPELINE_TRIGGER` are generated in GitLab and then added to GitHub.
14
+
15
+
`GIT_USER` is the username of whoever will be authenticated when pushing to GitLab for the mirror action. Since we then manually trigger CI after that, and explicitly skip CI here, this name is cosmetic.
16
+
17
+
a) GIT_PASSWORD
18
+
Go to Settings > Access Tokens. Click `Add new token`.
19
+
20
+
Pick a reasonable name & expiration date. (ie "GITHUB_PUSH_PASSWORD")
21
+
22
+
Pick the `Developer` role.
23
+
24
+
Under `Select scopes`, select `write_repository`.
25
+
26
+
Create.
27
+
28
+
Go to GitHub > Settings > Secrets and variables > Actions. Click `New repository secret`.
29
+
Name it `GIT_PASSWORD` and paste in the value generated from GitLab.
30
+
31
+
Add secret.
32
+
33
+
b) PNNL_PIPELINE_TRIGGER
34
+
Go to Settings > CI/CD > Pipeline trigger tokens. Click `Add new token`.
35
+
36
+
Give it a name and click create.
37
+
38
+
Go to GitHub > Settings > Secrets and variables > Actions. Click `New repository secret`.
39
+
Name it `PNNL_PIPELINE_TRIGGER` and paste in the value generated from GitLab.
40
+
41
+
2. Push back status & modules
42
+
43
+
In our module rebuild pipelines, we rebuild spack modules on each PNNL platform, then commit the new module paths/hashes back to the repository.
44
+
45
+
a) Generate token #1 (`GITLAB_MIRROR_STATUS`)
46
+
47
+
Go to your GitHub profile > Settings > Developer Settings > Personal access tokens > Fine-grained tokens.
48
+
49
+
Generate new token:
50
+
```
51
+
resource owner = pnnl
52
+
select repositories = pnnl/exago
53
+
permissions > repository permissions > commit statuses (read and write)
54
+
copy this token
55
+
```
56
+
57
+
Go to GitLab > Settings > CI/CD > Variables:
58
+
```
59
+
add variable
60
+
type = file
61
+
do not protect/mask/expand
62
+
key = GITHUB_CURL_HEADER
63
+
Value = `Authorization: token <token value>`
64
+
```
65
+
66
+
See https://ecp-ci.gitlab.io/docs/guides/build-status-gitlab.html for more details.
67
+
68
+
b) Generate token #2 (`GITLAB_COMMIT`)
69
+
70
+
Go to your GitHub profile > Settings > Developer Settings > Personal access tokens > Fine-grained tokens.
71
+
72
+
Generate new token:
73
+
```
74
+
resource owner = pnnl
75
+
select repositories = pnnl/exago
76
+
permissions > repository permissions > contents (read and write)
77
+
<copy this token>
78
+
```
79
+
80
+
Go to GitLab > Settings > CI/CD > Variables:
81
+
```
82
+
add variable
83
+
type = variable
84
+
do not protect
85
+
key = SPACK_GIT_TOKEN
86
+
<paste in value field>
87
+
```
88
+
89
+
## Change path to `.gitlab-ci.yml`
90
+
91
+
Go to > Settings > CI/CD > General Pipelines, change the `CI/CD configuration file` to the correct path to `.gitlab-ci.yml`.
92
+
93
+
In our repo, the path is `.gitlab/pnnl/.gitlab-ci.yml`.
0 commit comments