Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 50s
70 lines
2.9 KiB
YAML
70 lines
2.9 KiB
YAML
name: Gitea Actions Demo
|
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
on: [push]
|
|
|
|
jobs:
|
|
Explore-Gitea-Actions:
|
|
runs-on: nodejs
|
|
container:
|
|
image: node:24-alpine
|
|
volumes:
|
|
- /var/data/zApps:/var/data/zApps
|
|
- /var/data/zUser/apps:/var/data/zUser/apps
|
|
- /var/data/zApps/bin/docker/docker:/usr/bin/docker
|
|
steps:
|
|
- run: echo "GOPATH=/var/data/zUser/apps/go" >> $GITHUB_ENV
|
|
- run: echo "PATH=/var/data/zApps/bin:/var/data/zUser/apps/node/bin:/var/data/zUser/apps/go/bin:/var/data/zApps/go/bin:$PATH" >> $GITHUB_ENV
|
|
- 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: Check out repository code
|
|
uses: https://git.0orz.top/actions/checkout@v6.0.2
|
|
with:
|
|
fetch-depth: 1
|
|
- 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 }}
|
|
- name: Check go version
|
|
run: |
|
|
go version
|
|
- name: Run golangci-lint
|
|
run: |
|
|
cd ${{ gitea.workspace }}
|
|
golangci-lint run ./...
|
|
- name: Tests
|
|
run: |
|
|
cd ${{ gitea.workspace }}
|
|
go test -cover ./...
|
|
- name: Go build
|
|
run: |
|
|
cd ${{ gitea.workspace }}
|
|
export CGO_ENABLED=0
|
|
go build -ldflags "-X main.version=1.0.0-${{ gitea.sha }}" -o helloapp .
|
|
- name: Check Docker
|
|
run: |
|
|
docker --version
|
|
- name: Login to Harbor
|
|
run: |
|
|
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login localhost:8180 -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin
|
|
- name: Build Docker image
|
|
run: |
|
|
cd ${{ gitea.workspace }}
|
|
docker build -t localhost:8180/go-example/go-example:${{ gitea.sha }} .
|
|
- name: Push Docker image to local registry
|
|
run: |
|
|
docker push localhost:8180/go-example/go-example:${{ gitea.sha }}
|
|
- name: Update manifest and Push to Git
|
|
run: |
|
|
# 使用 kustomize 或 sed 修改镜像版本
|
|
sed -i "s|image: .*:.*|image: localhost:8180/go-example/go-example:${{ gitea.sha }}|g" deployment.yaml
|
|
|
|
# 配置 Git 并提交回仓库
|
|
git config --global user.name "Gitea Action"
|
|
git config --global user.email "action@gitea.io"
|
|
git add deployment.yaml
|
|
git commit -m "chore: update image to ${{ gitea.sha }} [skip ci]"
|
|
git push origin main
|
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|