-
Notifications
You must be signed in to change notification settings - Fork 3
107 lines (88 loc) · 3.41 KB
/
python_publish_release_management.yaml
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
name: Merge with main branch
on:
pull_request:
types: [closed]
branches:
- main
jobs:
main-pr-merge:
if: github.event.pull_request.merged == true
permissions: write-all
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release_action_plan.outputs.releases_created }}
matrix: ${{ steps.create-matrix.outputs.matrix }} # noqa: unknown-context
steps:
- name: Checkout our repository
uses: actions/checkout@v2
with:
ref: main
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Release Please
id: release_action_plan
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: .github/configuration/release-please-config.json
manifest-file: .github/configuration/release-please-manifest.json
include-component-in-tag: true
target-branch: main
- name: Create matrix for release
id: create-matrix
uses: actions/github-script@v5
with:
script: |
const allOutputs = ${{ toJson(steps.release_action_plan.outputs) }};
const pathsReleased = JSON.parse('${{ steps.release_action_plan.outputs.paths_released }}');
console.log("Processing paths:", pathsReleased);
const includeArray = pathsReleased.map((path) => {
if (!path.endsWith('code-confluence-flow-bridge')) {
console.log(`Skipping non-docker component: ${path}`);
return null;
}
const name = allOutputs[`${path}--name`];
const tag_name = allOutputs[`${path}--tag_name`];
const image_name = name.split(':')[0].trim();
const version = tag_name.split('-v')[1];
console.log(`Processing docker component: ${path} -> ${image_name}:${version}`);
return { path, image_name, version };
}).filter(item => item !== null);
console.log("Final Docker Matrix:", includeArray);
core.setOutput('matrix', JSON.stringify({ include: includeArray }));
release-docker-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: main-pr-merge
permissions:
contents: read
packages: write
if: needs.main-pr-merge.outputs.release_created == 'true'
strategy:
matrix: ${{ fromJson(needs.main-pr-merge.outputs.matrix) }} # noqa: unknown-context
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: main
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.path }}
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ matrix.version }}