-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (55 loc) · 1.81 KB
/
docker-build.yml
File metadata and controls
66 lines (55 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# .github/workflows/docker-build.yml
name: Source Pull + Docker Build
on:
workflow_dispatch:
permissions:
contents: read
packages: write
env:
DOCKER_REGISTRY: "ghcr.io"
SOURCE_REPOSITORY: "owner/source-repo"
SOURCE_REF: "main"
SOURCE_DIRECTORY: "public"
IMAGE_NAME: "my-nginx-image"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Current Repository
uses: actions/checkout@v6
- name: Checkout Source Repository
uses: actions/checkout@v6
with:
repository: ${{ env.SOURCE_REPOSITORY }}
ref: ${{ env.SOURCE_REF }}
path: ./source
ssh-key: ${{ secrets.SOURCE_DEPLOYMENT_KEY || '' }}
- name: Remove Git metadata
run: rm -rf source/.git
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine Docker Tag
id: docker_meta
uses: docker/metadata-action@v6
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.SOURCE_REF }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,scope=${{ github.workflow }}
build-args: |
SOURCE_DIRECTORY=${{ env.SOURCE_DIRECTORY }}