Compare commits

...

19 Commits

Author SHA1 Message Date
esinio
264f9333aa Update README.md
Add a  local prod example
2025-02-13 12:31:57 +08:00
lab
64336b1c23 fix: remove setup-go image of runs-on 2023-11-15 22:01:19 +08:00
lab
3441b00dbf feat: add setup-go test 2023-11-15 21:55:28 +08:00
lab
fb3b248014 fix: remove steps echos 2023-11-10 10:11:27 +08:00
lab
59ed3387a0 fix: github workflows syntax 2023-11-10 10:09:12 +08:00
lab
9f2876f8a2 fix: gihub workflow usage 2023-11-10 10:03:31 +08:00
lab
dd48a9ebf5 feat: add github workflows 2023-11-10 09:56:47 +08:00
lab
23aaa86d3e fix: runner command 2023-11-10 09:27:32 +08:00
lab
11cbeb9196 fix: hidden docker repository name 2023-11-10 09:15:49 +08:00
lab
e1d2802621 fix: change runner step build-push-action version from v4 to v2 2023-11-09 21:14:59 +08:00
lab
5e14683cd8 fix: add container image 2023-11-09 17:15:02 +08:00
lab
c164b34821 rm: incorrect dir 2023-11-09 14:17:10 +08:00
lab
3215109165 fix: retry actions 2023-11-09 12:07:46 +08:00
lab
120a7af640 fix: remove runner step of qemu 2023-11-09 11:36:39 +08:00
lab
d037c3af76 fix: runner repo path 2023-11-09 11:25:00 +08:00
lab
575f43452d fix: remove runner step of qemu 2023-11-09 11:21:27 +08:00
lab
c05d7cf1df fix: rollback runner checkout version from v5 to v3 2023-11-09 11:18:51 +08:00
lab
e5e0c12511 fix: right actions dir 2023-11-09 11:13:10 +08:00
lab
39a9b7f887 fix: NowHandler outputs format 2023-11-09 11:03:41 +08:00
7 changed files with 170 additions and 33 deletions

View File

@@ -1,31 +0,0 @@
name: ci
on:
push:
branches:
- "main"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: |
esinio/gitea-runner-ci-demo:latest

View File

@@ -0,0 +1,42 @@
name: Gitea Actions CI Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
push:
branches:
- "main"
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Checkout repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: https://github.com/docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:latest
- run: echo "🍏 This job's status is ${{ job.status }}."

42
.github/workflows/ci-demo.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Github Actions CI Demo
run-name: ${{ github.actor }} is testing out Github Actions of docker 🚀
on:
push:
branches:
- "main"
jobs:
Explore-Github-Actions:
runs-on: ubuntu-latest
steps:
-
run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
-
run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Github!"
-
run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:latest

50
.github/workflows/setup-go.yaml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Test setup-go Actions
run-name: ${{ github.actor }} is testing out Github Actions of setup-go 🚀
on:
push:
branches:
- "main"
jobs:
Explore-Github-Actions:
runs-on: ubuntu-latest
steps:
-
name: Show details
run: |
echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Github!"
echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
-
name: Checkout repository code
uses: actions/checkout@v4
-
name: List files in the repository
run: |
echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
echo "🖥️ The workflow is now ready to test your code on the runner."
ls ${{ github.workspace }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Setup golang
uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'
-
name: Run golang scripts
run: |
go env -w GOPROXY='https://goproxy.cn,direct'
go env
go run cmd/helloworld/main.go
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

View File

@@ -1,3 +1,30 @@
# gitea-runner-ci-demo
A gitea runner ci demo
### gitea runner
``` shell
docker run -itd \
-e GITEA_RUNNER_NAME=<gitea-runner-name> \
-e GITEA_INSTANCE_URL=<gitea-server> \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<gitea-runner-token> \
-v /var/run/docker.sock:/var/run/docker.sock \
--name gitea_runner \
gitea/act_runner:latest
```
``` shell
docker run \
-v $PWD/config.yaml:/config.yaml \
-v $PWD/data:/data \
-v $PWD/cache:/root/.cache \
-v /var/run/docker.sock:/var/run/docker.sock \
-e CONFIG_FILE=/config.yaml \
-e GITEA_INSTANCE_URL=https://gitea.example.com/ \
-e GITEA_RUNNER_REGISTRATION_TOKEN=mytoken \
-e GITEA_RUNNER_NAME=local-cached \
-p 18000:18000 \
-d gitea/act_runner:nightly
```

7
cmd/helloworld/main.go Normal file
View File

@@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}

View File

@@ -32,6 +32,6 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
func TimeHandler(w http.ResponseWriter, r *http.Request) {
now := time.Now()
res := now.GoString()
res := now.Format(time.RFC3339Nano)
fmt.Fprint(w, res)
}