Skip to content

Commit

Permalink
Merge pull request #1 from internetarchive/ext
Browse files Browse the repository at this point in the history
github/gitlab unified CI/CD
  • Loading branch information
traceypooh authored Dec 30, 2024
2 parents 8d75474 + 170901f commit 1a5797d
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 33 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.git
.github
11 changes: 11 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on: [push, workflow_dispatch]
jobs:
cicd:
# https://github.com/internetarchive/cicd
uses: internetarchive/cicd/.github/workflows/cicd.yml@main
with:
NOMAD_VAR_HOSTNAMES: '["nomad","nomad.archive.org"]'
NOMAD_VAR_MEMORY: 100 # xxx
NOMAD_VAR_CHECK_PROTOCOL: 'tcp'
secrets:
NOMAD_TOKEN_EXT: ${{ secrets.NOMAD_TOKEN_EXT }}
50 changes: 50 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

name: copy repo & deploy to GitHub Pages

on:
workflow_call:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./

# Deploy to GitHub Pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
9 changes: 9 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
admin off
}

:5000 {
# We answer all requests this CI/CD yaml file from this repo
file_server
rewrite * /gitlab.yml
}
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ RUN mkdir -m777 /usr/local/sbin && \
rm nomad.zip && \
chmod 777 nomad && \
# podman for build.sh
apk add bash zsh jq podman && \
apk add bash zsh jq podman caddy && \
# using podman not docker
ln -s /usr/bin/podman /usr/bin/docker

WORKDIR /app
COPY gitlab.yml Caddyfile ./

COPY build.sh deploy.sh /

# revisit this:
# USER deno
USER deno

# NOTE: `nomad` binary needed for other repositories using us for CI/CD - but drop from _our_ webapp.
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 })"'
CMD ["/usr/sbin/caddy", "run"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ Uses:
- simply make your project have this simple `.gitlab-ci.yml` in top-level dir:
```yaml
include:
- remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/.gitlab-ci.yml'
- remote: 'https://nomad.archive.org'
```
*OR*
```yaml
include:
- remote: 'https://raw.githubusercontent.com/internetarchive/nomad/refs/heads/main/gitlab.yml'
```
- if you want a [test] phase, you can add this to the `.gitlab-ci.yml` file above:
```yaml
test:
Expand Down
23 changes: 0 additions & 23 deletions build.yml

This file was deleted.

26 changes: 22 additions & 4 deletions .gitlab-ci.yml → gitlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,28 @@ stages:
- deploy
- cleanup


include:
# GitLab Auto DevOps' stock CI/CD [build] phase:
- remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/build.yml'
build:
# Tracey 3/2024:
# This was adapted & simplified from:
# https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
stage: build
# If need to rebuild this image while runners are down, `cd` to this directory, then, as root:
# podman login registry.gitlab.com
# podman build --net=host --tag registry.gitlab.com/internetarchive/nomad/master . && sudo podman push registry.gitlab.com/internetarchive/nomad/master
image: registry.gitlab.com/internetarchive/nomad/master
variables:
DOCKER_HOST: 'unix:///run/podman/podman.sock'
DOCKER_TLS_CERTDIR: ''
DOCKER_BUILDKIT: 1
script:
- /build.sh
artifacts:
reports:
dotenv: gl-auto-build-variables.env
rules:
- if: '$BUILD_DISABLED'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'

test-ourself:
stage: test
Expand Down

0 comments on commit 1a5797d

Please sign in to comment.