-
Notifications
You must be signed in to change notification settings - Fork 6
48 lines (40 loc) · 1.14 KB
/
build-container.yaml
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
name: "Build Django image"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set REGISTRY env variable
run: echo "REGISTRY=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build container image
uses: docker/build-push-action@v4
id: build-image
with:
context: ./.
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{env.REGISTRY}}:${{github.run_number}}, ${{env.REGISTRY}}:latest
cache-from: type=gha
cache-to: type=gha,mode=max