Skip to content

Commit a350b78

Browse files
authored
Create main.yml
creating main yml for github action
1 parent 8a40ab3 commit a350b78

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Push to Container Registry
2+
on:
3+
push:
4+
branches:
5+
- main
6+
env:
7+
REGISTRY: ghcr.io
8+
REPO_OWNER: ${{ github.repository_owner }}
9+
10+
jobs:
11+
build-and-push:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Build with Maven
18+
run: mvn clean install
19+
20+
- name: Log in Github Container Registry
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ${{ env.REGISTRY }}
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GH_TOKEN }}
26+
27+
- name: Extract image metadata
28+
id: meta
29+
uses: docker/metadata-action@v4
30+
with:
31+
images: ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/spring-boot-redis-cache
32+
33+
- name: Build and push
34+
uses: docker/build-push-action@v4
35+
with:
36+
context: .
37+
file: Dockerfile
38+
push: true
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}
41+
build-args: |
42+
GITHUB_TOKEN=${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)