-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 1.7 KB
/
docker.yml
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
name: Build and push Docker image
on:
push:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
packages: write
if: github.repository == 'PluralKit/avatars'
steps:
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" | sed 's|/|-|g' >> $GITHUB_ENV
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ env.BRANCH_NAME }}
type=raw,value=${{ github.sha }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
flavor: |
latest=false
- name: Build Cache for Docker
uses: actions/cache@v3
with:
path: rust-build-cache
key: ${{ runner.os }}-rust-build-cache-${{ hashFiles('**/Cargo.lock') }}
- name: inject rust-build-cache into docker
# v1 was composed of two actions: "inject" and "extract".
# v2 is unified to a single action.
uses: reproducible-containers/buildkit-cache-dance@v2.1.2
with:
cache-source: rust-build-cache
cache-target: /app/target
- uses: docker/build-push-action@v2
with:
# https://github.com/docker/build-push-action/issues/378
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/pluralkit/avatars:${{ env.BRANCH_NAME }}
cache-to: type=inline