Skip to content

Commit 1d390a8

Browse files
author
Ricardo Rosales
committed
[GitHub Actions] Added support for building and pushing container images to ghcr.io
1 parent 0ac4ee4 commit 1d390a8

File tree

1 file changed

+38
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)