github和gitlab actions语法总结
# gitlab
# 环境配置、登录等
before_script:在每个作业的 script 阶段之前执行
# 必须存在 具体的业务逻辑
script:作业的主要执行部分,包含实际执行的命令或脚本
# 任务清理、收集日志、发送通知等
after_script:在每个作业的 script 阶段之后执行
1
2
3
4
5
6
2
3
4
5
6
# 总结
1. github使用 steps, 相关的命令 包装在了 uses 里面
2. gitlab使用 stages, 相关的命令包装在了 image 里面
1
2
2
# gitlab
stages:
- build
build-job:
stage: build
image: alpine/git
before_script:
- export HARBOR_HOST="AAA"
script:
- mkdir -p /kaniko/.docker
- echo "hello world test"
- curl "https://open.feishu.cn/open-apis/bot/v2/hook/xxx-xxx-xxx-xxx" -H "Content-Type:application/json" -d "{ \"msg_type\":\"interactive\", \"card\": { \"config\": { \"wide_screen_mode\": false, \"enable_forward\": true }, \"header\": { \"title\": { \"content\": \"Github Action\", \"tag\": \"plain_text\" } }, \"elements\": [ { \"tag\": \"markdown\", \"content\": \"test\" }, { \"actions\": [ { \"tag\": \"button\", \"text\": { \"tag\": \"lark_md\", \"content\": \"View Build Logs\", \"lines\": 1 }, \"url\": \"test\", \"type\": \"primary\", \"value\": { } } ], \"tag\": \"action\", \"layout\": \"bisected\" }, { \"tag\": \"note\", \"elements\": [ { \"tag\": \"plain_text\", \"content\": \"$(date)\" } ] } ] } }"
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# github
name: Image
on:
push:
branches:
- dev
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name:
run: cat /home/runner/.m2/settings.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
上次更新: 2023-07-31 10:01:32