Skip to content

Commit 57557ee

Browse files
authored
Update publish-ghcr.yml
1 parent 849d043 commit 57557ee

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

.github/workflows/publish-ghcr.yml

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,61 @@
1-
name: Docker image CI for GHCR
2-
1+
name: Build and Push Docker Image
32
on:
43
push:
54
branches:
6-
- add-actions
5+
- main
6+
- develop
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
715

816
jobs:
917
build:
1018
runs-on: ubuntu-latest
11-
19+
20+
# Permissões necessárias para o GITHUB_TOKEN
21+
permissions:
22+
contents: read
23+
packages: write
24+
1225
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v4
15-
16-
- name: Log in to GitHub Container Registry
17-
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
18-
19-
- name: Build Docker image
20-
run: docker build -t ghcr.io/librecodecoop/nextcloud-images:30 -f .docker/app/Dockerfile .
21-
22-
- name: Push Docker image
23-
run: docker push ghcr.io/librecodecoop/nextcloud-images:30
24-
25-
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=sha,prefix={{branch}}-
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
platforms: linux/amd64
57+
push: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)