-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.49 KB
/
build.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
# Build image from every merge to main or with a build tag.
name: Build image
on:
push:
branches:
- main
tags:
- build/**
env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
# HACK: remove
REPOSITORY_DOWNCASED: briansigafoos/docker-rails-webpacker-app
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
# Required for cache-from and cache-to support
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# https://github.com/docker/login-action
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: true
secrets: "rails_master_key=${{ secrets.RAILS_MASTER_KEY }}"
tags: ${{ inputs.package }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY_DOWNCASED }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY_DOWNCASED }}:buildcache,mode=max
# TODO: switch to type=gha caching once it works/is stable.
# cache-from: type=gha
# cache-to: type=gha,mode=max