Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github/gitlab unified CI/CD #1

Merged
merged 10 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading