Skip to content

Commit 5a769f5

Browse files
Update Dockerfile
1 parent 74ec9cc commit 5a769f5

File tree

5 files changed

+546
-12
lines changed

5 files changed

+546
-12
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
env:
12+
IMAGE_NAME: cloudinary/cli
13+
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Extract short SHA
19+
id: sha
20+
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
21+
22+
- name: Set up QEMU (for multi-arch)
23+
uses: docker/setup-qemu-action@v3
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
with:
28+
install: true
29+
30+
- name: Log in to Docker Hub
31+
uses: docker/login-action@v2
32+
with:
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
36+
- name: Extract version
37+
id: version
38+
run: |
39+
if [[ "${{ github.event_name }}" == "release" ]]; then
40+
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
41+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
42+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
43+
else
44+
echo "version=${{ steps.sha.outputs.sha }}" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Build and push image
48+
uses: docker/build-push-action@v4
49+
with:
50+
context: .
51+
push: true
52+
platforms: linux/amd64,linux/arm64
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
55+
tags: |
56+
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
57+
${{ env.IMAGE_NAME }}:${{ steps.sha.outputs.sha }}
58+
${{ env.IMAGE_NAME }}:latest

0 commit comments

Comments
 (0)