Skip to content

Commit 1a5797d

Browse files
authored
Merge pull request #1 from internetarchive/ext
github/gitlab unified CI/CD
2 parents 8d75474 + 170901f commit 1a5797d

File tree

8 files changed

+106
-33
lines changed

8 files changed

+106
-33
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.git
2+
.github

.github/workflows/cicd.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
on: [push, workflow_dispatch]
2+
jobs:
3+
cicd:
4+
# https://github.com/internetarchive/cicd
5+
uses: internetarchive/cicd/.github/workflows/cicd.yml@main
6+
with:
7+
NOMAD_VAR_HOSTNAMES: '["nomad","nomad.archive.org"]'
8+
NOMAD_VAR_MEMORY: 100 # xxx
9+
NOMAD_VAR_CHECK_PROTOCOL: 'tcp'
10+
secrets:
11+
NOMAD_TOKEN_EXT: ${{ secrets.NOMAD_TOKEN_EXT }}

.github/workflows/pages.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
2+
3+
name: copy repo & deploy to GitHub Pages
4+
5+
on:
6+
workflow_call:
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-24.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
lfs: true
32+
fetch-depth: 0
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v5
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
path: ./
39+
40+
# Deploy to GitHub Pages
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
needs: build
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

Caddyfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
admin off
3+
}
4+
5+
:5000 {
6+
# We answer all requests this CI/CD yaml file from this repo
7+
file_server
8+
rewrite * /gitlab.yml
9+
}

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ RUN mkdir -m777 /usr/local/sbin && \
88
rm nomad.zip && \
99
chmod 777 nomad && \
1010
# podman for build.sh
11-
apk add bash zsh jq podman && \
11+
apk add bash zsh jq podman caddy && \
1212
# using podman not docker
1313
ln -s /usr/bin/podman /usr/bin/docker
1414

15+
WORKDIR /app
16+
COPY gitlab.yml Caddyfile ./
17+
1518
COPY build.sh deploy.sh /
1619

17-
# revisit this:
18-
# USER deno
20+
USER deno
1921

20-
# NOTE: `nomad` binary needed for other repositories using us for CI/CD - but drop from _our_ webapp.
21-
CMD rm /usr/local/sbin/nomad /usr/bin/podman && su deno -c 'deno eval "import { serve } from \"https://deno.land/std/http/server.ts\"; serve(() => new Response(\"hai\"), { port: 5000 })"'
22+
CMD ["/usr/sbin/caddy", "run"]

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ Uses:
2929
- simply make your project have this simple `.gitlab-ci.yml` in top-level dir:
3030
```yaml
3131
include:
32-
- remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/.gitlab-ci.yml'
32+
- remote: 'https://nomad.archive.org'
3333
```
34+
*OR*
35+
```yaml
36+
include:
37+
- remote: 'https://raw.githubusercontent.com/internetarchive/nomad/refs/heads/main/gitlab.yml'
38+
```
39+
3440
- if you want a [test] phase, you can add this to the `.gitlab-ci.yml` file above:
3541
```yaml
3642
test:

build.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitlab-ci.yml renamed to gitlab.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,28 @@ stages:
1717
- deploy
1818
- cleanup
1919

20-
21-
include:
22-
# GitLab Auto DevOps' stock CI/CD [build] phase:
23-
- remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/build.yml'
20+
build:
21+
# Tracey 3/2024:
22+
# This was adapted & simplified from:
23+
# https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
24+
stage: build
25+
# If need to rebuild this image while runners are down, `cd` to this directory, then, as root:
26+
# podman login registry.gitlab.com
27+
# podman build --net=host --tag registry.gitlab.com/internetarchive/nomad/master . && sudo podman push registry.gitlab.com/internetarchive/nomad/master
28+
image: registry.gitlab.com/internetarchive/nomad/master
29+
variables:
30+
DOCKER_HOST: 'unix:///run/podman/podman.sock'
31+
DOCKER_TLS_CERTDIR: ''
32+
DOCKER_BUILDKIT: 1
33+
script:
34+
- /build.sh
35+
artifacts:
36+
reports:
37+
dotenv: gl-auto-build-variables.env
38+
rules:
39+
- if: '$BUILD_DISABLED'
40+
when: never
41+
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
2442

2543
test-ourself:
2644
stage: test

0 commit comments

Comments
 (0)