Skip to content

Commit

Permalink
[GitHub Actions] Added support for building and pushing container ima…
Browse files Browse the repository at this point in the history
…ges to ghcr.io
  • Loading branch information
missingcharacter committed Sep 18, 2023
1 parent b4989a0 commit 865f2a8
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker image

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
generate-tag:
runs-on: windows-2022
outputs:
image_tag: ${{ steps.gen-image-tag.outputs.image_tag }}
steps:
- uses: actions/checkout@v3
- name: Generate image tag
shell: bash
id: gen-image-tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
ref=PR-${{ github.event.number }}
# NOTE: we tag images with the head commit so they can be easily tagged/deployed,
# but on pull requests the image is actually built with the merge commit
head_commit=${{ github.event.pull_request.head.sha }}
else
ref=${{ github.ref_name }}
head_commit=${{ github.sha }}
fi
# for PRs: PR-11850.37.e7426df
# for push (develop/main/master): master.37.e7426df
echo "image_tag=${ref}.${{ github.run_number }}.$(echo ${head_commit} | cut -c1-7)" >> $GITHUB_OUTPUT
build-without-jdk:
needs: generate-tag
permissions: write-all
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- uses: mr-smithers-excellent/docker-build-push@v6
with:
image: adf-shir
tags: ${{ needs.generate-tag.outputs.image_tag }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
build-with-jdk:
needs: generate-tag
permissions: write-all
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- uses: mr-smithers-excellent/docker-build-push@v6
with:
image: adf-shir
tags: ${{ needs.generate-tag.outputs.image_tag }}-jdk11
buildArgs: "INSTALL_JDK=true"
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 865f2a8

Please sign in to comment.