generated from Netcracker/qubership-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (103 loc) · 3.32 KB
/
push.yml
File metadata and controls
106 lines (103 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Build Artifacts
permissions:
contents: read
packages: write
actions: read
on:
release:
types: [created]
push:
branches:
- '**'
paths-ignore:
- 'docs/**'
- 'CODE-OF-CONDUCT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
pull_request:
branches:
- '**'
paths-ignore:
- 'docs/**'
- 'CODE-OF-CONDUCT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
env:
TAG_NAME: ${{ github.event.release.tag_name || github.ref }}
GITHUB_GROUP: ${{ github.repository_owner }}
concurrency:
# On main/release, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# More info: https://stackoverflow.com/a/68422069/253468
group: ${{ github.ref == 'refs/heads/main' && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
cancel-in-progress: true
jobs:
multiplatform_build:
if: github.event.pull_request.user.login != 'dependabot[bot]' || github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
component:
- name: qubership-docker-kubectl
file: Dockerfile
context: ""
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- 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:
registry: ghcr.io
username: ${GITHUB_ACTOR}
password: ${{secrets.GITHUB_TOKEN}}
- name: Prepare Tag
run: echo "TAG_NAME=$(echo ${TAG_NAME} | sed 's@refs/tags/@@;s@refs/heads/@@;s@/@_@g')" >> $GITHUB_ENV
- name: Prepare Group
run: echo "GITHUB_GROUP=${GITHUB_GROUP,,}" >> $GITHUB_ENV
- name: Derive major tag
id: semver
shell: bash
run: |
if [[ "$RAW" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
MAJOR="${RAW%%.*}"
echo "MAJOR_TAG=$MAJOR" >> "$GITHUB_ENV"
echo "has_major=true" >> "$GITHUB_OUTPUT"
else
echo "MAJOR_TAG=" >> "$GITHUB_ENV"
echo "has_major=false" >> "$GITHUB_OUTPUT"
fi
- name: Compose image tags
shell: bash
run: |
IMAGE="ghcr.io/${GITHUB_GROUP}/${{ matrix.component.name }}"
TAGS="${IMAGE}:${TAG_NAME}"
if [[ -n "${MAJOR_TAG}" ]]; then
TAGS="${TAGS},${IMAGE}:${MAJOR_TAG}"
fi
echo "TAGS=${TAGS}" >> "$GITHUB_ENV"
- name: Get package IDs for delete
id: get-ids-for-delete
uses: Netcracker/get-package-ids@v0.0.1
with:
component-name: ${{ matrix.component.name }}
component-tag: ${{ env.TAG_NAME }}
access-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
no-cache: true
context: ${{ matrix.component.context }}
file: ${{ matrix.component.file }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
tags: ${{ env.TAGS }}
provenance: false