Skip to content

Commit d358837

Browse files
committed
trigger gitlab pipleine from gh action
1 parent 550480d commit d358837

12 files changed

+70
-198
lines changed

.github/workflows/build-images.yml

+15-53
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,22 @@
1-
name: Build Images
1+
name: Trigger GitLab CI
22

33
on:
4-
push:
5-
branches:
6-
- github-runner
4+
workflow_run:
5+
workflows: ["Srtool build", "Deploy Chain docs"]
6+
types:
7+
- completed
78

89
jobs:
9-
build-images:
10+
trigger_gitlab:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1012
runs-on: ubuntu-latest
11-
timeout-minutes: 120
12-
env:
13-
DOCKER_HUB_PARACHAIN: kiltprotocol/kilt-node
14-
DOCKER_HUB_STANDALONE: kiltprotocol/standalone-node
15-
DOCKER_HUB_DIP_PROVIDER_TEMPLATE: kiltprotocol/dip-provider-node-template
16-
DOCKER_HUB_DIP_CONSUMER_TEMPLATE: kiltprotocol/dip-consumer-node-template
17-
AWS_REGISTRY: ${{ secrets.ECR_REGISTRY }}
18-
CI_COMMIT_SHORT_SHA: ${{ github.sha }}
19-
CI_COMMIT_BRANCH: ${{ github.ref_name }}
20-
CI_COMMIT_TAG: ${{ github.ref_name }}
2113
steps:
22-
- name: Free Disk Space
23-
uses: jlumbroso/free-disk-space@main
24-
with:
25-
tool-cache: true
26-
27-
- name: Checkout
28-
uses: actions/checkout@v4
29-
30-
- name: Display AWS and Docker Versions
31-
run: |
32-
aws --version
33-
docker --version
34-
35-
- name: Log in to Docker Hub
36-
uses: docker/login-action@v3
37-
with:
38-
username: ${{ secrets.DOCKER_USER }}
39-
password: ${{ secrets.DOCKERHUB_TOKEN }}
40-
41-
- name: Login to ECR
42-
uses: docker/login-action@v3
43-
with:
44-
registry: ${{ secrets.ECR_REGISTRY }}
45-
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
46-
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
47-
48-
- name: Build Docker Images
49-
run: |
50-
./.maintain/build-image.sh build
51-
52-
- name: Push Image - Tag
53-
if: startsWith(github.ref, 'refs/tags/')
54-
run: |
55-
./.maintain/push-image.sh build "${{ env.CI_COMMIT_TAG }}"
56-
57-
- name: Push Image - Latest
58-
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-rc') && !contains(github.ref, 'dev-')
14+
- name: Trigger GitLab CI
15+
env:
16+
GITLAB_TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
17+
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
5918
run: |
60-
./.maintain/push-image.sh build "latest"
19+
curl -X POST \
20+
-F token=$GITLAB_TRIGGER_TOKEN \
21+
-F ref=${{ github.ref_name }} \
22+
https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/trigger/pipeline

.github/workflows/check-clippy-all-features.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
~/.cargo/registry/index/
3939
~/.cargo/registry/cache/
4040
~/.cargo/git/db/
41-
key: $ ${{ github.job }}-${{ github.ref }}-clippy-all-features-${{ hashFiles('**/Cargo.lock') }}
41+
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-all-features-${{ hashFiles('**/Cargo.lock') }}
4242
restore-keys: |
43-
$ ${{ github.job }}-${{ github.ref }}-clippy-all-features-
43+
$ ${{ github.job }}-${{ github.ref_name }}-clippy-all-features-
4444
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
@@ -55,6 +55,5 @@ jobs:
5555
-e SKIP_WASM_BUILD=1 \
5656
paritytech/ci-unified:bullseye-1.74.0 \
5757
bash -c "
58-
cargo clippy --all-targets --all-features --locked --quiet && \
59-
chown -R $(id -u):$(id -g) target/"
58+
cargo clippy --all-targets --all-features --locked --quiet
6059

.github/workflows/check-clippy.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
~/.cargo/registry/index/
3939
~/.cargo/registry/cache/
4040
~/.cargo/git/db/
41-
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
41+
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
4242
restore-keys: |
43-
$ ${{ github.job }}-${{ github.ref }}-clippy-
43+
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
4444
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
@@ -55,5 +55,4 @@ jobs:
5555
-e SKIP_WASM_BUILD=1 \
5656
paritytech/ci-unified:bullseye-1.74.0 \
5757
bash -c "
58-
cargo clippy --all-targets --locked --quiet && \
59-
chown -R $(id -u):$(id -g) target/"
58+
cargo clippy --all-targets --locked --quiet

.github/workflows/check-rustdoc.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
~/.cargo/registry/index/
3939
~/.cargo/registry/cache/
4040
~/.cargo/git/db/
41-
key: $ ${{ github.job }}-${{ github.ref }}-rustdoc-${{ hashFiles('**/Cargo.lock') }}
41+
key: $ ${{ github.job }}-${{ github.ref_name }}-rustdoc-${{ hashFiles('**/Cargo.lock') }}
4242
restore-keys: |
43-
$ ${{ github.job }}-${{ github.ref }}-rustdoc-
43+
$ ${{ github.job }}-${{ github.ref_name }}-rustdoc-
4444
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
@@ -55,5 +55,4 @@ jobs:
5555
-e SKIP_WASM_BUILD=1 \
5656
paritytech/ci-unified:bullseye-1.74.0 \
5757
bash -c "
58-
cargo doc --all-features --no-deps --locked && \
59-
chown -R $(id -u):$(id -g) target/"
58+
cargo doc --all-features --no-deps --locked

.github/workflows/docs-publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy Chain docs
1+
name: Deploy Chain docs
22

33
on:
44
push:

.github/workflows/test-all-features.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
~/.cargo/registry/index/
3939
~/.cargo/registry/cache/
4040
~/.cargo/git/db/
41-
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
41+
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
4242
restore-keys: |
43-
$ ${{ github.job }}-${{ github.ref }}-clippy-
43+
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
4444
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
@@ -55,5 +55,4 @@ jobs:
5555
-e SKIP_WASM_BUILD=1 \
5656
paritytech/ci-unified:bullseye-1.74.0 \
5757
bash -c "
58-
cargo test --all-features --all-targets --locked && \
59-
chown -R $(id -u):$(id -g) target/"
58+
cargo test --all-features --all-targets --locked

.github/workflows/test.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
~/.cargo/registry/index/
3939
~/.cargo/registry/cache/
4040
~/.cargo/git/db/
41-
key: $ ${{ github.job }}-${{ github.ref }}-clippy-${{ hashFiles('**/Cargo.lock') }}
41+
key: $ ${{ github.job }}-${{ github.ref_name }}-clippy-${{ hashFiles('**/Cargo.lock') }}
4242
restore-keys: |
43-
$ ${{ github.job }}-${{ github.ref }}-clippy-
43+
$ ${{ github.job }}-${{ github.ref_name }}-clippy-
4444
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
@@ -55,5 +55,4 @@ jobs:
5555
-e SKIP_WASM_BUILD=1 \
5656
paritytech/ci-unified:bullseye-1.74.0 \
5757
bash -c "
58-
cargo test --all-targets --locked && \
59-
chown -R $(id -u):$(id -g) target/"
58+
cargo test --all-targets --locked

.gitlab-ci.yml

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
default:
2-
interruptible: true
3-
4-
.check_skip_rust:
1+
build-images:
2+
timeout: 2 hours
3+
image:
4+
name: kiltprotocol/kilt-ci:2.7.31
5+
entrypoint: [""]
6+
stage: build
7+
only:
8+
refs:
9+
- develop
10+
- master
11+
- /^[0-9]+(?:\.[0-9]+){2}(?:-(rc)*([0-9])+)?$/
12+
- /^[dev-](\w*-)*[0-9]?$/
13+
variables:
14+
DOCKER_HUB_PARACHAIN: "kiltprotocol/kilt-node"
15+
DOCKER_HUB_STANDALONE: "kiltprotocol/standalone-node"
16+
DOCKER_HUB_DIP_PROVIDER_TEMPLATE: "kiltprotocol/dip-provider-node-template"
17+
DOCKER_HUB_DIP_CONSUMER_TEMPLATE: "kiltprotocol/dip-consumer-node-template"
518
before_script:
6-
- |-
7-
if echo "$CI_COMMIT_TITLE" | grep -q "ci-skip-rust"; then
8-
echo "Skipping rust tests due to commit title"
9-
exit 0
10-
fi
11-
include:
12-
- local: '.gitlab/check.yml'
13-
- local: '.gitlab/test.yml'
14-
- local: '.gitlab/build.yml'
15-
16-
variables:
17-
CARGO_CACHE_PATH: $CARGO_CACHE_PATH
18-
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo
19+
- aws --version
20+
- docker --version
21+
script:
22+
- echo -n $CI_REGISTRY_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
23+
- aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_REGISTRY
24+
- ./.maintain/docker-auth-config.sh
1925

20-
workflow:
21-
auto_cancel:
22-
on_new_commit: interruptible
26+
- ./.maintain/build-image.sh build
27+
- "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_SHORT_SHA}; fi"
28+
- "if [[ ! -z ${CI_COMMIT_BRANCH} ]]; then ./.maintain/push-image.sh build latest-${CI_COMMIT_BRANCH}; fi"
29+
- "if [[ ! -z ${CI_COMMIT_TAG} ]]; then ./.maintain/push-image.sh build ${CI_COMMIT_TAG}; fi"
30+
- "if [[ ! -z ${CI_COMMIT_TAG} && ! -z ${CI_COMMIT_TAG##*-rc*} && ! -z ${CI_COMMIT_TAG##*dev-*} ]]; then ./.maintain/push-image.sh build latest; fi"
2331

24-
stages:
25-
- check
26-
- test
27-
- build

.gitlab/build.yml

-29
This file was deleted.

.gitlab/check.yml

-41
This file was deleted.

.gitlab/test.yml

-23
This file was deleted.

.maintain/build-image.sh

+11-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ set -e
44

55
target_tag=$1
66

7-
# Build the builder image and push it sequentially
7+
# Build the builder image and push it in the background
88
docker build \
99
--target builder \
1010
--cache-from $AWS_REGISTRY/kilt-parachain/collator:builder \
1111
-t $AWS_REGISTRY/kilt-parachain/collator:builder \
12-
.
12+
. &
13+
docker push $AWS_REGISTRY/kilt-parachain/collator:builder &
1314

14-
docker push $AWS_REGISTRY/kilt-parachain/collator:builder
15+
wait
1516

17+
# Build and tag images in parallel
1618
build_and_tag() {
1719
local node_type=$1
1820
local image_name=$2
@@ -26,10 +28,12 @@ build_and_tag() {
2628
.
2729
}
2830

29-
build_and_tag "kilt-parachain" "kilt-node" "kilt-parachain/collator"
31+
build_and_tag "kilt-parachain" "kilt-node" "kilt-parachain/collator" &
3032

31-
build_and_tag "standalone-node" "standalone-node" "kilt/prototype-chain"
33+
build_and_tag "standalone-node" "standalone-node" "kilt/prototype-chain" &
3234

33-
build_and_tag "dip-provider-node-template" "dip-provider-node-template" "kilt-parachain/collator"
35+
build_and_tag "dip-provider-node-template" "dip-provider-node-template" "kilt-parachain/collator" &
3436

35-
build_and_tag "dip-consumer-node-template" "dip-consumer-node-template" "kilt-parachain/collator"
37+
build_and_tag "dip-consumer-node-template" "dip-consumer-node-template" "kilt-parachain/collator" &
38+
39+
wait

0 commit comments

Comments
 (0)