Skip to content

Commit 00b4b08

Browse files
committed
ADD: publish docker image in Github Container Registry
1 parent 991068c commit 00b4b08

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/build.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set some env vars for the build
29+
run: |
30+
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
31+
echo "COMMIT=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
32+
echo "LASTMOD=${TIMESTAMP}" >> $GITHUB_ENV
33+
echo "IMAGE_NAME=redirect2me/siterank" >> $GITHUB_ENV
34+
35+
- name: Build and push
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
file: ./Dockerfile
40+
push: true
41+
tags: |
42+
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
43+
ghcr.io/${{ env.IMAGE_NAME }}:latest
44+
build-args: |
45+
COMMIT=${{ env.COMMIT }}
46+
LASTMOD=${{ env.LASTMOD }}
47+

0 commit comments

Comments
 (0)