-
Notifications
You must be signed in to change notification settings - Fork 14
100 lines (82 loc) · 2.64 KB
/
Copy pathpublish-docker-image.yml
File metadata and controls
100 lines (82 loc) · 2.64 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Build and Publish Docker Image
on:
workflow_call:
inputs:
flavor:
description: "Defines global behaviors for tags (e.g. 'latest=auto')"
required: false
type: string
docker_file:
description: "Path to the deployment file"
required: false
type: string
default: "deployment/Dockerfile"
images:
description: "Docker image names (e.g. 'ghcr.io/FuelLabs/repository-name')"
required: true
type: string
labels:
description: "Docker image labels (e.g. 'com.example.label=value')"
required: false
type: string
tags:
description: "Docker image tags (e.g. 'latest,1.0.0')"
required: true
type: string
secrets:
GH_TOKEN:
description: "GitHub Token"
required: true
GITHUB_CONTAINER_USERNAME:
description: "Username for GitHub Container Registry"
required: true
GITHUB_CONTAINER_PASSWORD:
description: "Password for GitHub Container Registry"
required: true
SLACK_WEBHOOK_URL:
description: "Slack Webhook URL"
required: true
env:
GITHUB_CONTAINNER_REGISTRY_URL: ghcr.io
jobs:
build-and-publish-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Docker Meta
id: meta
uses: docker/metadata-action@v3
with:
flavor: ${{ inputs.flavor }}
images: ${{ inputs.images }}
labels: ${{ inputs.labels }}
tags: ${{ inputs.tags }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.GITHUB_CONTAINNER_REGISTRY_URL }}
username: ${{ secrets.GITHUB_CONTAINER_USERNAME }}
password: ${{ secrets.GITHUB_CONTAINER_PASSWORD }}
- name: Build and publish image to Github Container Registry
uses: docker/build-push-action@v2
with:
context: .
file: ${{ inputs.docker_file }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
notify-slack-action:
needs: cargo-toml-lint
if: ${{failure()}}
uses: FuelLabs/github-actions/.github/workflows/notify-slack-action.yml@master
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}