-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (38 loc) · 1.09 KB
/
push_to_ghcr.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
name: Push to ghcr.io
on:
push:
branches:
- main
- master
pull_request:
jobs:
build_and_push:
name: Build and push
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Build Timestamp
run: echo "BUILD_TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S:%z')" >> $GITHUB_ENV
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
env:
BUILD_BRANCH: ${{ github.head_ref || github.ref_name }}
with:
context: .
target: app
push: true
build-args: |
BUILD_BRANCH=${{ env.BUILD_BRANCH }}
BUILD_COMMIT=${{ github.sha }}
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ env.BUILD_BRANCH }}