Skip to content

Commit c30dfe7

Browse files
march
1 parent 97076dc commit c30dfe7

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

.github/workflows/docker-image.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Node-scan
2+
23
on:
34
schedule:
4-
- cron: '00 5 * * *'
5+
- cron: '0 5 * * *'
56
push:
67
branches: ["master"]
78
paths:
@@ -12,43 +13,42 @@ on:
1213
- 'docker/**'
1314

1415
env:
15-
IMAGE_NAME: "node-scan"
16-
VERSION: "latest"
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
1718

1819
jobs:
19-
test:
20-
runs-on: [ ubuntu-latest ]
20+
build:
21+
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
2127
steps:
22-
- uses: actions/checkout@v3
23-
- name: Build test
24-
run: |
25-
docker build -t tst:${GITHUB_SHA::5} -f docker/Dockerfile .
26-
docker images | grep ${GITHUB_SHA::5} > version.txt
27-
- name: Commit changes
28-
uses: EndBug/add-and-commit@v9
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Log into registry ${{ env.REGISTRY }}
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
2934
with:
30-
author_name: RootShell-coder
31-
author_email: Root.Shelling@gmail.com
32-
message: 'upd'
33-
add: 'version.*'
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
3438

35-
push:
36-
needs: [ test ]
37-
name: Publish to Docker Hub
38-
runs-on: [ ubuntu-latest ]
39-
steps:
40-
- uses: actions/checkout@v3
41-
- name: Build image
42-
run: |
43-
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${GITHUB_SHA::5} -f docker/Dockerfile .
44-
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${GITHUB_SHA::5} ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${VERSION}
45-
- name: Login to Docker Hub
46-
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
47-
- name: Push Image to Docker Hub
48-
run: |
49-
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${GITHUB_SHA::5}
50-
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${VERSION}
51-
- name: Delete images
52-
run: |
53-
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${GITHUB_SHA::5}
54-
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${VERSION}
39+
- name: Extract Docker metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
47+
- name: Build and push Docker image
48+
uses: docker/build-push-action@v5
49+
with:
50+
platforms: linux/amd64,linux/arm64
51+
context: docker
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)