-
Notifications
You must be signed in to change notification settings - Fork 31
95 lines (82 loc) · 3.17 KB
/
cc-job-image-base.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
name: Build CC-Job-Image-Base
run-name: Building CC-Job-Image-Base
on:
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: build
permissions:
contents: read
packages: write
env:
platforms: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker-Buildx
uses: docker/setup-buildx-action@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}
- name: docker-auth
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Read Version
id: read_version
run: |
version=$(cat JOB_IMAGE_BASE_VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build and Push Base Image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/cc-utils/job-image-base:${{ steps.read_version.outputs.version }}
file: Dockerfile.job-image-base
update-base-image-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
new_version: ${{ steps.update_version.outputs.new_version }}
current_version: ${{ steps.update_version.outputs.current_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Git Identity
uses: ./.github/actions/setup-git-identity
- name: Update Base Image and Increment Version
id: update_version
run: |
current_version=$(cat JOB_IMAGE_BASE_VERSION)
sed -i "s|^ARG BASE_IMAGE=.*|ARG BASE_IMAGE=ghcr.io/${{ github.repository_owner }}\
/cc-utils/job-image-base:$current_version|" Dockerfile
new_version=$(echo $current_version | awk -F. '{printf "%d.%d.%d", $1, $2+1, $3}')
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "$new_version" > JOB_IMAGE_BASE_VERSION
- name: Commit and Push Changes
run: |
git add Dockerfile JOB_IMAGE_BASE_VERSION
git commit -m "Update job-image to use job-image-base \
version ${{ steps.update_version.outputs.current_version }} \
and prepare for ${{ steps.update_version.outputs.new_version }}"
git checkout -b update-base-image
git push origin update-base-image --force
- name: Create Pull Request
run: |
gh pr create \
-B master \
-H update-base-image \
--title "Update job-image to use version ${{ steps.update_version.outputs.current_version }}" \
--body "Updates the job-image to use the latest job-image-base version:
- Base Image Version: ${{ steps.update_version.outputs.current_version }}.
- Also increments the version to ${{ steps.update_version.outputs.new_version }}."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}