Skip to content

Commit 50202a7

Browse files
committed
ci: better ci
1 parent 05ed61c commit 50202a7

File tree

3 files changed

+71
-78
lines changed

3 files changed

+71
-78
lines changed

.github/workflows/__shared-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ name: Internal - Common Continuous Integration tasks
22

33
on:
44
workflow_call:
5+
inputs:
6+
tag:
7+
description: "Tag Version (semver - x.x.x)"
8+
type: string
9+
required: false
10+
outputs:
11+
built-images:
12+
value: ${{ jobs.docker-build-images.outputs.built-images }}
513

614
jobs:
715

@@ -101,3 +109,28 @@ jobs:
101109
if: steps.list-changed.outputs.changed == 'true'
102110
run: ct install --target-branch ${{ github.event.repository.default_branch }}
103111

112+
docker-build-images:
113+
name: Docker Build Images
114+
needs: [golangci-lint, go-test, go-coverage, chart-testing]
115+
uses: hoverkraft-tech/ci-github-container/.github/workflows/docker-build-images.yml@0.14.4
116+
permissions:
117+
contents: read
118+
id-token: write
119+
issues: read
120+
packages: write
121+
pull-requests: read
122+
secrets:
123+
oci-registry-password: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
runs-on: '["self-hosted"]'
126+
oci-registry: "ghcr.io"
127+
images: |
128+
[{
129+
"name": "app",
130+
"tag": "${{ inputs.tag }}",
131+
"dockerfile": "./Dockerfile",
132+
"platforms": [
133+
"linux/amd64",
134+
"linux/arm64"
135+
]
136+
}]

.github/workflows/main-ci.yml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,3 @@ jobs:
3939
"linux/arm64"
4040
]
4141
}]
42-
43-
dockerhub-publish:
44-
name: Dockerhub Publish
45-
needs: docker-build-images
46-
runs-on: self-hosted
47-
steps:
48-
- uses: docker/login-action@v3
49-
with:
50-
registry: "ghcr.io"
51-
username: ${{ github.repository_owner }}
52-
password: ${{ secrets.GITHUB_TOKEN }}
53-
54-
- uses: docker/login-action@v3
55-
with:
56-
registry: "docker.io"
57-
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
58-
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
59-
60-
- name: Push built images to Docker.io
61-
run: |
62-
APP_IMAGE="${{ fromJson(needs.docker-build-images.outputs.built-images).app.images[0] }}"
63-
docker pull "$APP_IMAGE"
64-
APP_TAG="${{ fromJson(needs.docker-build-images.outputs.built-images).APP.tags[0] }}"
65-
APP_REGISTRY_PATH="docker.io/webofmars"
66-
APP_DOCKERIO_IMAGE="${APP_REGISTRY_PATH}/http-header-authenticator:$APP_TAG"
67-
docker tag "$APP_IMAGE" "$APP_DOCKERIO_IMAGE"
68-
docker push "$APP_DOCKERIO_IMAGE"
69-
70-
update_release_draft:
71-
# we want to publish a new tag only if ci succeeds
72-
needs: ci
73-
permissions:
74-
contents: write
75-
pull-requests: write
76-
runs-on: self-hosted
77-
steps:
78-
- uses: release-drafter/release-drafter@v6
79-
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
with:
82-
publish: true
83-
disable-autolabeler: true

.github/workflows/release.yml

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
tagVersion:
77
description: "Tag Version (semver - x.x.x)"
88
required: true
9-
push:
10-
tags:
11-
- '[0-9]+.[0-9]+.[0-9]+'
129

1310
jobs:
1411
check-branches:
@@ -27,6 +24,44 @@ jobs:
2724
name: Continuous Integration
2825
uses: ./.github/workflows/__shared-ci.yml
2926

27+
update_release_draft:
28+
# we want to publish a new tag only if ci succeeds
29+
needs: ci
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
runs-on: self-hosted
34+
steps:
35+
- id: update_release_draft
36+
uses: release-drafter/release-drafter@v6
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
publish: true
41+
disable-autolabeler: true
42+
43+
- uses: docker/login-action@v3
44+
with:
45+
registry: "ghcr.io"
46+
username: ${{ github.repository_owner }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- uses: docker/login-action@v3
50+
with:
51+
registry: "docker.io"
52+
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
53+
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
54+
55+
- name: Push built images to Docker.io
56+
run: |
57+
APP_IMAGE="${{ fromJson(needs.ci.outputs.built-images).app.images[0] }}"
58+
docker pull "$APP_IMAGE"
59+
APP_TAG="${{ steps.update_release_draft.outputs.tag_name }}"
60+
APP_REGISTRY_PATH="docker.io/webofmars"
61+
APP_DOCKERIO_IMAGE="${APP_REGISTRY_PATH}/http-header-authenticator:$APP_TAG"
62+
docker tag "$APP_IMAGE" "$APP_DOCKERIO_IMAGE"
63+
docker push "$APP_DOCKERIO_IMAGE"
64+
3065
helm-push:
3166
name: 👷‍♂️ Run helm push
3267
needs: ci
@@ -64,36 +99,3 @@ jobs:
6499
update-dependencies: true
65100
version: ${{ github.event.inputs.tagVersion }}
66101
appVersion: ${{ github.event.inputs.tagVersion }}
67-
68-
release:
69-
name: 📦 Release
70-
needs:
71-
- skaffold-build
72-
- helm-push
73-
runs-on: self-hosted
74-
steps:
75-
- uses: tibdex/github-app-token@v2
76-
id: generate-token
77-
with:
78-
app_id: ${{ vars.CI_BOT_APP_ID }}
79-
private_key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
80-
81-
# checkout code
82-
- uses: actions/checkout@v4
83-
with:
84-
fetch-depth: 0
85-
86-
- name: Generate changelog
87-
id: changelog
88-
uses: metcalfc/changelog-generator@v4.3.1
89-
with:
90-
myToken: ${{ steps.generate-token.outputs.token }}
91-
92-
- name: Create a GitHub release
93-
uses: actions/create-release@v1
94-
env:
95-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
96-
with:
97-
tag_name: ${{ github.event.inputs.tagVersion }}
98-
release_name: Release ${{ github.event.inputs.tagVersion }}
99-
body: ${{ steps.changelog.outputs.changelog }}

0 commit comments

Comments
 (0)