Compare commits
No commits in common. "golang-ubuntu-latest" and "master" have entirely different histories.
golang-ubu
...
master
|
@ -2,28 +2,47 @@ name: push
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- golang-ubuntu-latest
|
||||
- master
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: golang-ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@focs
|
||||
- name: Display Go version
|
||||
run: go version
|
||||
- name: Prepare
|
||||
run: |
|
||||
go env -w GO111MODULE=on
|
||||
go env -w GOPROXY=https://goproxy.cn,direct
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519.pub
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519.pub
|
||||
ssh-keyscan -p 2222 focs.ji.sjtu.edu.cn >> ~/.ssh/known_hosts
|
||||
ssh -T git@focs.ji.sjtu.edu.cn -p 2222
|
||||
shell: bash
|
||||
- name: Determine build command
|
||||
id: build_command
|
||||
run: |
|
||||
if echo "${{ github.event.head_commit.message }}" | grep -q "force build"; then
|
||||
echo "build_command=make force-build" >> $GITHUB_ENV
|
||||
if echo "${{ gitea.event.head_commit.message }}" | grep -q "force build"; then
|
||||
echo "build_command=make force-build" >> $GITEA_ENV
|
||||
else
|
||||
echo "build_command=make build" >> $GITHUB_ENV
|
||||
echo "build_command=make build" >> $GITEA_ENV
|
||||
fi
|
||||
- name: Build
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
run: ${{ env.build_command }}
|
||||
- name: Test
|
||||
run: make test
|
||||
- name: Check images
|
||||
run: docker images
|
||||
- name: Remove dangling images
|
||||
run: docker image prune -f
|
||||
- name: Docker Login
|
||||
run: "echo \"${{ secrets.DOCKER_PASSWORD }}\" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin focs.ji.sjtu.edu.cn:5000 \n"
|
||||
run: |
|
||||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin focs.ji.sjtu.edu.cn:5000
|
||||
- name: Docker Push
|
||||
run: make push
|
||||
|
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/bin/joj3
|
||||
/bin/repo-health-checker
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "JOJ3"]
|
||||
path = JOJ3
|
||||
url = ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/JOJ3.git
|
36
Dockerfile
36
Dockerfile
|
@ -1,22 +1,26 @@
|
|||
FROM focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest
|
||||
FROM focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest-slim
|
||||
|
||||
ARG GO_VERSION=1.24.1
|
||||
ARG GOLANGCI_LINT_VERSION=1.64.8
|
||||
ENV PATH=$PATH:/usr/local/go/bin:/root/go/bin
|
||||
ENV TZ="Asia/Shanghai"
|
||||
|
||||
RUN sed -i s@/archive.ubuntu.com/@/mirrors.tuna.tsinghua.edu.cn/@g /etc/apt/sources.list && \
|
||||
RUN sed -i s@/deb.debian.org/@/mirrors.tuna.tsinghua.edu.cn/@g /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends upx && \
|
||||
apt-get install -y --no-install-recommends sudo python3-minimal python3-pip git git-lfs openssh-client rsync && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
userdel -r node && \
|
||||
useradd -u 1000 -ms /bin/bash tt && \
|
||||
useradd -u 1001 -ms /bin/bash student && \
|
||||
usermod -aG student tt && \
|
||||
echo "student ALL=(tt) NOPASSWD:SETENV:/usr/local/bin/joj3,/usr/local/bin/joj3-forge-convert\ntt ALL=(student) NOPASSWD:SETENV:ALL" > /etc/sudoers.d/joj
|
||||
|
||||
RUN wget -q https://studygolang.com/dl/golang/go${GO_VERSION}.linux-amd64.tar.gz && \
|
||||
rm -rf /usr/local/go && \
|
||||
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
|
||||
rm go${GO_VERSION}.linux-amd64.tar.gz
|
||||
# install joint-teapot && joj3-forge
|
||||
RUN pip install --no-cache-dir --break-system-packages \
|
||||
--index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
git+https://focs.ji.sjtu.edu.cn/git/JOJ/Joint-Teapot \
|
||||
git+https://focs.ji.sjtu.edu.cn/git/JOJ/JOJ3-config-generator
|
||||
|
||||
RUN wget -q https://ghfast.top/https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz && \
|
||||
tar -C /tmp -xzf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz && \
|
||||
rm -rf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz && \
|
||||
mkdir -p /root/go/bin && \
|
||||
mv /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /root/go/bin
|
||||
# install joj3 & repo-health-checker & joj3-forge-convert
|
||||
COPY bin/joj3 bin/repo-health-checker bin/joj3-forge-convert /usr/local/bin/
|
||||
|
||||
USER student
|
||||
WORKDIR /home/student
|
||||
|
|
1
JOJ3
Submodule
1
JOJ3
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 0ea767264023f7ea5189d65ddd5c0d9f2e4d67ca
|
25
Makefile
25
Makefile
|
@ -1,12 +1,25 @@
|
|||
.PHONY: all force-build build push
|
||||
.PHONY: all prepare force-build build test push
|
||||
|
||||
IMAGE_NAME := focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim
|
||||
|
||||
all: build
|
||||
|
||||
force-build:
|
||||
docker build --no-cache -t focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest .
|
||||
prepare:
|
||||
git submodule update --init --remote
|
||||
$(MAKE) -C JOJ3
|
||||
cp JOJ3/build/joj3 JOJ3/build/repo-health-checker bin/
|
||||
ls -lha bin
|
||||
upx --best bin/joj3 bin/repo-health-checker
|
||||
ls -lha bin
|
||||
|
||||
build:
|
||||
docker build -t focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest .
|
||||
force-build: prepare
|
||||
docker build --no-cache -t $(IMAGE_NAME) .
|
||||
|
||||
build: prepare
|
||||
docker build -t $(IMAGE_NAME) .
|
||||
|
||||
test:
|
||||
docker run --rm $(IMAGE_NAME) sudo -u tt -E joj3 --help
|
||||
|
||||
push:
|
||||
docker push focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest
|
||||
docker push $(IMAGE_NAME)
|
||||
|
|
13
README.md
13
README.md
|
@ -1,3 +1,12 @@
|
|||
# Runner Images with Golang
|
||||
# Runner Images
|
||||
|
||||
Actions for this branch will build and push `focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest` image.
|
||||
FOCS docker images used by [act_runner](https://gitea.com/gitea/act_runner) to run workflows.
|
||||
|
||||
Check <https://gitea.com/gitea/runner-images> for information about base images.
|
||||
|
||||
Actions for this branch will build and push `focs.ji.sjtu.edu.cn:5000/gitea/runner-images:focs-ubuntu-latest-slim` image.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Put `joj3` into `/bin` or run `make prepare`
|
||||
2. `make build && make push` on a machine that can access `focs.ji.sjtu.edu.cn:5000`
|
||||
|
|
18
bin/joj3-forge-convert
Executable file
18
bin/joj3-forge-convert
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/bash
|
||||
set -e
|
||||
COURSE=$1
|
||||
REPO_PATH=/home/tt/.cache/$COURSE-config
|
||||
GIT_USER=$(whoami)
|
||||
GIT_HOSTNAME=$(hostname -s)
|
||||
GIT_EMAIL="${GIT_USER}@${GIT_HOSTNAME}"
|
||||
git -C $REPO_PATH pull --rebase
|
||||
rsync -r --delete $REPO_PATH/home/tt/.config/ /home/tt/.config
|
||||
joj3-forge convert /home/tt/.config/joj
|
||||
rsync -r --delete /home/tt/.config/joj/ $REPO_PATH/home/tt/.config/joj
|
||||
git -C $REPO_PATH config user.name $GIT_USER
|
||||
git -C $REPO_PATH config user.email $GIT_EMAIL
|
||||
git -C $REPO_PATH add home/tt/.config/joj
|
||||
if ! git -C "$REPO_PATH" diff --staged --quiet; then
|
||||
git -C $REPO_PATH commit -m "chore: joj3-forge convert"
|
||||
git -C $REPO_PATH push
|
||||
fi
|
Loading…
Reference in New Issue
Block a user