-
Notifications
You must be signed in to change notification settings - Fork 4
37 lines (35 loc) · 1.18 KB
/
docker-image.yaml
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
name: Build, Test and Release the Docker Image
on:
# On each branch/commit
push:
paths:
- 'docker-image/**'
- '.github/workflows/docker-image.yaml'
# On each pull request
pull_request:
# Manually
workflow_dispatch: {}
jobs:
build:
runs-on: ubuntu-latest
# Allow push to GHCR registry
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
permissions:
packages: write
contents: read
env:
IMAGE_NAME: "ghcr.io/${{ github.repository_owner }}/jenkins-example:${{ github.sha }}"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: 'docker build --tag ${IMAGE_NAME} --label "gha_run_number=${GITHUB_RUN_ID}" ./docker-image/'
- name: Push image
run: 'docker push $IMAGE_NAME'
if: github.event_name != 'pull_request'