Skip to content

Commit 4bfad9c

Browse files
committed
WIP
1 parent 0df72c4 commit 4bfad9c

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Update Docker Build Image
2+
3+
on:
4+
schedule:
5+
# A day after creating the tag from https://github.com/DataDog/dd-trace-java-docker-build/blob/master/.github/workflows/docker-tag.yml
6+
- cron: '0 0 1 2,5,8,11 *'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'The tag to use for the Docker build image'
11+
required: true
12+
default: 'vYY.MM-base'
13+
14+
jobs:
15+
update-docker-build-image:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout the repository
20+
uses: actions/checkout@v2
21+
- name: Download ghcommit CLI
22+
run: |
23+
curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
24+
chmod +x /usr/local/bin/ghcommit
25+
- name: Pick a branch name
26+
id: define-branch
27+
run: echo "branch=ci/update-docker-build-image-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
28+
- name: Create branch
29+
run: |
30+
git checkout -b ${{ steps.define-branch.outputs.branch }}
31+
git push -u origin ${{ steps.define-branch.outputs.branch }} --force
32+
- name: Define the Docker build image tage to use
33+
id: define-tag
34+
run: |
35+
if [ -z "${{ github.event.inputs.tag }}" ]; then
36+
TAG=${{ github.event.inputs.tag }}
37+
else
38+
current_month=$(date +%m)
39+
current_year=$(date +%y)
40+
case $current_month in
41+
01) TAG_DATE="$$(($current_year - 1)).10" ;;
42+
02|03|04) TAG_DATE="${current_year}.01" ;;
43+
05|06|07) TAG_DATE="${current_year}.04" ;;
44+
08|09|10) TAG_DATE="${current_year}.07" ;;
45+
11|12) TAG_DATE="${current_year}.10" ;;
46+
esac
47+
TAG = "v${TAG_DATE}-base"
48+
fi
49+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
50+
echo "::notice::Using Docker build image tag: ${TAG}"
51+
- name: Update the Docker build image in CircleCI config
52+
run: |
53+
sed -i 's|DOCKER_IMAGE_VERSION=.*|DOCKER_IMAGE_VERSION="${{ steps.define-tag.outputs.tag }}"|' .circleci/render_config.py
54+
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .circleci/render_config.py --message "feat(ci): Update Docker build image"
55+
- name: Update the Docker build image in GitLab CI config
56+
run: |
57+
sed -i 's|image: ghcr.io/datadog/dd-trace-java-docker-build:.*|image: ghcr.io/datadog/dd-trace-java-docker-build:${{ steps.define-tag.outputs.tag }}|' .gitlab-ci.yml
58+
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .gitlab-ci.yml --message "feat(ci): Update Docker build image"
59+
- name: Create pull request
60+
env:
61+
GH_TOKEN: ${{ github.token }}
62+
run: |
63+
# use echo to set a multiline body for the PR
64+
gh pr create --title "Update Docker build image" \
65+
--base master \
66+
--head ${{ steps.define-branch.outputs.branch }} \
67+
--label "comp: tooling" \
68+
--label "type: enhancement" \
69+
--label "tag: no release notes" \
70+
--body "This PR updates the Docker build image to ${{ steps.define-tag.outputs.tag }}."
71+
72+
73+

0 commit comments

Comments
 (0)