Skip to content

Commit 4fbd345

Browse files
authored
CI: Enable tagging with latest based on user input (#174)
1 parent f0c2986 commit 4fbd345

File tree

1 file changed

+63
-12
lines changed

1 file changed

+63
-12
lines changed

.github/workflows/manual_build.yml

+63-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
type: string
1212
default: "stable"
1313
required: true
14+
set_latest:
15+
description: 'Tag as latest'
16+
type: boolean
17+
default: false
1418
env:
1519
IMAGE_NAME: godot-ci
1620
jobs:
@@ -33,13 +37,58 @@ jobs:
3337
else
3438
echo "dotnet_version=mcr.microsoft.com/dotnet/sdk:8.0-jammy" >> $GITHUB_OUTPUT
3539
fi
36-
40+
get_tags:
41+
name: Get Tags
42+
runs-on: ubuntu-22.04
43+
outputs:
44+
tags: ${{steps.write_tags.outputs.tags}}
45+
tags_mono: ${{steps.write_tags_mono.outputs.tags}}
46+
steps:
47+
- run: echo IMAGE_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
48+
- run: echo IMAGE_TAG=$(echo ${{ github.event.inputs.release_name != 'stable' && format('.{0}', github.event.inputs.release_name) || '' }}) >> $GITHUB_ENV
49+
- name: Set tags
50+
run: |
51+
echo "ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}" >> tags.txt
52+
echo "${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}" >> tags.txt
53+
- name: Set latest tags
54+
if: ${{inputs.set_latest}}
55+
run: |
56+
echo "ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest" >> tags.txt
57+
echo "${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest" >> tags.txt
58+
- name: Set Mono tags
59+
run: |
60+
echo "ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:mono-${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}" >> tags_mono.txt
61+
echo "${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:mono-${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}" >> tags_mono.txt
62+
- name: Set Mono latest tags
63+
if: ${{inputs.set_latest}}
64+
run: |
65+
echo "ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:mono-latest" >> tags_mono.txt
66+
echo "${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:mono-latest" >> tags_mono.txt
67+
- uses: actions/upload-artifact@v4
68+
with:
69+
name: image_tags
70+
path: tags.txt
71+
retention-days: 1
72+
- uses: actions/upload-artifact@v4
73+
with:
74+
name: image_tags_mono
75+
path: tags_mono.txt
76+
retention-days: 1
3777
build:
3878
name: Build Image
3979
runs-on: ubuntu-22.04
80+
needs: get_tags
4081
steps:
82+
- uses: actions/download-artifact@v4
83+
with:
84+
name: image_tags
85+
- run: |
86+
{
87+
echo 'TAGS<<EOF'
88+
cat tags.txt
89+
echo EOF
90+
} >> "$GITHUB_ENV"
4191
- uses: actions/checkout@v3
42-
- run: echo IMAGE_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
4392
- name: Login to GitHub Container Registry
4493
uses: docker/[email protected]
4594
with:
@@ -51,16 +100,13 @@ jobs:
51100
with:
52101
username: ${{ secrets.DOCKERHUB_USERNAME }}
53102
password: ${{ secrets.DOCKERHUB_TOKEN }}
54-
- run: echo IMAGE_TAG=$(echo ${{ github.event.inputs.release_name != 'stable' && format('.{0}', github.event.inputs.release_name) || '' }}) >> $GITHUB_ENV
55103
- name: Build and push Docker images
56104
uses: docker/[email protected]
57105
with:
58106
context: .
59107
file: Dockerfile
60108
push: true
61-
tags: |
62-
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}
63-
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}
109+
tags: ${{ env.TAGS }}
64110
build-args: |
65111
GODOT_VERSION=${{ github.event.inputs.version }}
66112
RELEASE_NAME=${{ github.event.inputs.release_name }}
@@ -70,10 +116,18 @@ jobs:
70116
build-mono:
71117
name: Build Mono Image
72118
runs-on: ubuntu-22.04
73-
needs: [version]
119+
needs: [version, get_tags]
74120
steps:
121+
- uses: actions/download-artifact@v4
122+
with:
123+
name: image_tags_mono
124+
- run: |
125+
{
126+
echo 'TAGS<<EOF'
127+
cat tags_mono.txt
128+
echo EOF
129+
} >> "$GITHUB_ENV"
75130
- uses: actions/checkout@v3
76-
- run: echo IMAGE_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
77131
- name: Login to GitHub Container Registry
78132
uses: docker/[email protected]
79133
with:
@@ -85,16 +139,13 @@ jobs:
85139
with:
86140
username: ${{ secrets.DOCKERHUB_USERNAME }}
87141
password: ${{ secrets.DOCKERHUB_TOKEN }}
88-
- run: echo IMAGE_TAG=$(echo ${{ github.event.inputs.release_name != 'stable' && format('.{0}', github.event.inputs.release_name) || '' }}) >> $GITHUB_ENV
89142
- name: Build and push Docker images
90143
uses: docker/[email protected]
91144
with:
92145
context: .
93146
file: mono.Dockerfile
94147
push: true
95-
tags: |
96-
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:mono-${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}
97-
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:mono-${{ github.event.inputs.version }}${{ env.IMAGE_TAG }}
148+
tags: ${{ env.TAGS }}
98149
build-args: |
99150
IMAGE=${{ needs.version.outputs.dotnet_version }}
100151
GODOT_VERSION=${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)