-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.4 KB
/
build-and-release.yml
File metadata and controls
79 lines (66 loc) · 2.4 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
name: Build & Release Cerebro API
on:
push:
branches:
- main
paths:
- 'app/**'
- 'requirements.txt'
- 'Dockerfile'
- '.github/workflows/build-and-release.yml'
concurrency:
group: cerebro-api-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.commit.outputs.short }}
image_digest: ${{ steps.docker_build.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Organization Name
id: org_name
run: |
org_name=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "Organization Name: $org_name"
echo "org_name=$org_name" >> $GITHUB_OUTPUT
- name: Extract commit
id: commit
uses: prompt/actions-commit-hash@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ steps.org_name.outputs.org_name }}/gc-cerebro-api:latest
ghcr.io/${{ steps.org_name.outputs.org_name }}/gc-cerebro-api:${{ steps.commit.outputs.short }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image Summary
run: |
echo "## 🐳 Docker Image Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| **Image** | \`ghcr.io/${{ steps.org_name.outputs.org_name }}/gc-cerebro-api\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Tag** | \`${{ steps.commit.outputs.short }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Digest** | \`${{ steps.docker_build.outputs.digest }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Platforms** | \`linux/amd64, linux/arm64\` |" >> $GITHUB_STEP_SUMMARY