-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.59 KB
/
push-docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Build and Push Docker Image
on:
release:
types: [created]
workflow_dispatch:
inputs:
custom_tag:
description: 'Custom tag for manual trigger'
required: false
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get version from Chart.yaml
run: |
APP_VERSION=$(grep appVersion chart/Chart.yaml | cut -d ' ' -f 2 | tr -d '"')
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
- name: Determine release tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ -z "${{ github.event.inputs.custom_tag }}" ]; then
RELEASE_TAG="manual-trigger"
else
RELEASE_TAG="${{ github.event.inputs.custom_tag }}"
fi
else
RELEASE_TAG="${{ github.event.release.tag_name }}"
fi
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image with combined tag
run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }} -f dockerfiles/Dockerfile .
- name: Push Docker image to GitHub Container Registry
run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }}