Skip to content

Commit 865f2a8

Browse files
[GitHub Actions] Added support for building and pushing container images to ghcr.io
1 parent b4989a0 commit 865f2a8

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
generate-tag:
12+
runs-on: windows-2022
13+
outputs:
14+
image_tag: ${{ steps.gen-image-tag.outputs.image_tag }}
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Generate image tag
18+
shell: bash
19+
id: gen-image-tag
20+
run: |
21+
if [ "${{ github.event_name }}" == "pull_request" ]; then
22+
ref=PR-${{ github.event.number }}
23+
# NOTE: we tag images with the head commit so they can be easily tagged/deployed,
24+
# but on pull requests the image is actually built with the merge commit
25+
head_commit=${{ github.event.pull_request.head.sha }}
26+
else
27+
ref=${{ github.ref_name }}
28+
head_commit=${{ github.sha }}
29+
fi
30+
# for PRs: PR-11850.37.e7426df
31+
# for push (develop/main/master): master.37.e7426df
32+
echo "image_tag=${ref}.${{ github.run_number }}.$(echo ${head_commit} | cut -c1-7)" >> $GITHUB_OUTPUT
33+
build-without-jdk:
34+
needs: generate-tag
35+
permissions: write-all
36+
runs-on: windows-2022
37+
steps:
38+
- uses: actions/checkout@v3
39+
- uses: mr-smithers-excellent/docker-build-push@v6
40+
with:
41+
image: adf-shir
42+
tags: ${{ needs.generate-tag.outputs.image_tag }}
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
build-with-jdk:
47+
needs: generate-tag
48+
permissions: write-all
49+
runs-on: windows-2022
50+
steps:
51+
- uses: actions/checkout@v3
52+
- uses: mr-smithers-excellent/docker-build-push@v6
53+
with:
54+
image: adf-shir
55+
tags: ${{ needs.generate-tag.outputs.image_tag }}-jdk11
56+
buildArgs: "INSTALL_JDK=true"
57+
registry: ghcr.io
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)