-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.75 KB
/
Copy pathdeploy.yml
File metadata and controls
60 lines (50 loc) · 1.75 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
name: Publish Docker to GitHub Container Registry
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
publish:
name: Build and publish to ghcr
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU (for multi-arch, optional)
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute lowercase repo and image tags
id: vars
run: |
repo_lower=$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')
image_sha="ghcr.io/${repo_lower}:${GITHUB_SHA}"
image_latest="ghcr.io/${repo_lower}:latest"
echo "repo_lower=${repo_lower}" >> $GITHUB_OUTPUT
echo "image_sha=${image_sha}" >> $GITHUB_OUTPUT
echo "image_latest=${image_latest}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ steps.vars.outputs.image_sha }}
${{ steps.vars.outputs.image_latest }}
cache-from: type=registry,ref=ghcr.io/${{ steps.vars.outputs.repo_lower }}:cache
cache-to: type=inline
- name: Output image information
run: |
echo "IMAGE=${{ steps.vars.outputs.image_sha }}" >> $GITHUB_OUTPUT
echo "Image published to ${{ steps.vars.outputs.image_sha }}"