-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (44 loc) · 1.23 KB
/
main.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
name: Build and Push Docker Image
on:
push:
branches:
- main
paths:
- Dockerfile
- .github/workflows/**
- requirements.txt
env:
DOCKER_BUILDKIT: 1
jobs:
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Get the current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> ${GITHUB_ENV}
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.REGISTRY_IMAGE }}:main-${{ env.CURRENT_DATE }}
${{ secrets.REGISTRY_IMAGE }}:main
cache-from: |
type=registry,ref=${{ secrets.REGISTRY_IMAGE }}:main
cache-to: |
type=inline