-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (43 loc) 路 1.32 KB
/
Copy pathdocker.build-push.yml
File metadata and controls
43 lines (43 loc) 路 1.32 KB
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
name: Action - Docker build & push
on:
workflow_call:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
jobs:
docker:
name: 'Build & Push'
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v4.2.0
- name: 'Generate build number'
run: |
BUILD_NUMBER=$(git rev-list --all --count)
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "This build is tagged as $BUILD_NUMBER on $GITHUB_REF"
- name: 'Log in to the Container registry'
uses: docker/login-action@v4.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Extract metadata (tags, labels) for Docker'
id: metadata
uses: docker/metadata-action@v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: 'Build and Push'
uses: docker/build-push-action@v7.3.0
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}