Skip to content

Commit 9d71523

Browse files
committed
Update docker-publish.yml
Signed-off-by: Md Imran <[email protected]>
1 parent 8b1eb00 commit 9d71523

File tree

1 file changed

+20
-84
lines changed

1 file changed

+20
-84
lines changed

.github/workflows/docker-publish.yml

+20-84
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,26 @@
1+
name: Build Docker Image
12
on:
23
push:
3-
branches: [ "master" ]
4-
# Publish semver tags as releases.
5-
tags: [ 'v*.*.*' ]
6-
pull_request:
7-
branches: [ "master" ]
8-
9-
env:
10-
# Use docker.io for Docker Hub if empty
11-
REGISTRY: docker.io
12-
# github.repository as <account>/<repo>
13-
IMAGE_NAME: ${{ github.repository }}
14-
15-
4+
branches:
5+
- master
166
jobs:
177
build:
18-
8+
name: push docker image to docker hub
199
runs-on: ubuntu-latest
20-
permissions:
21-
contents: read
22-
packages: write
23-
# This is used to complete the identity challenge
24-
# with sigstore/fulcio when running outside of PRs.
25-
id-token: write
26-
2710
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v4
30-
31-
# Install the cosign tool except on PR
32-
# https://github.com/sigstore/cosign-installer
33-
- name: Install cosign
34-
if: github.event_name != 'pull_request'
35-
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
36-
with:
37-
cosign-release: 'v2.2.4'
38-
39-
# Set up BuildKit Docker container builder to be able to build
40-
# multi-platform images and export cache
41-
# https://github.com/docker/setup-buildx-action
42-
- name: Set up Docker Buildx
43-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
44-
45-
# Login against a Docker registry except on PR
46-
# https://github.com/docker/login-action
47-
- name: Login to Docker Hub
48-
if: github.event_name != 'pull_request'
49-
uses: docker/login-action@v3
50-
with:
51-
username: ${{ vars.DOCKERHUB_USERNAME }}
52-
password: ${{ secrets.DOCKERHUB_TOKEN }}
53-
54-
# Extract metadata (tags, labels) for Docker
55-
# https://github.com/docker/metadata-action
56-
- name: Extract Docker metadata
57-
id: meta
58-
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
59-
with:
60-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61-
62-
# Build and push Docker image with Buildx (don't push on PR)
63-
# https://github.com/docker/build-push-action
64-
- name: Build and push Docker image
65-
id: build-and-push
66-
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
67-
with:
68-
context: .
69-
push: ${{ github.event_name != 'pull_request' }}
70-
tags: |
71-
${{ steps.meta.outputs.tags }}
72-
latest
73-
labels: ${{ steps.meta.outputs.labels }}
74-
cache-from: type=gha
75-
cache-to: type=gha,mode=max
76-
77-
# Sign the resulting Docker image digest except on PRs.
78-
# This will only write to the public Rekor transparency log when the Docker
79-
# repository is public to avoid leaking data. If you would like to publish
80-
# transparency data even for private images, pass --force to cosign below.
81-
# https://github.com/sigstore/cosign
82-
# - name: Sign the published Docker image
83-
# if: ${{ github.event_name != 'pull_request' }}
84-
# env:
85-
# # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
86-
# TAGS: ${{ steps.meta.outputs.tags }}
87-
# DIGEST: ${{ steps.build-and-push.outputs.digest }}
88-
# # This step uses the identity token to provision an ephemeral certificate
89-
# # against the sigstore community Fulcio instance.
90-
# run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
11+
- uses: actions/checkout@v2
12+
- name: login to docker hub
13+
id: docker-hub
14+
env:
15+
username: ${{vars.DOCKERHUB_USERNAME}}
16+
password: ${{secrets.DOCKERHUB_PASSWORD}}
17+
run: |
18+
docker login -u $username -p $password
19+
- name: build the docker image
20+
id: build-docker-image
21+
run: |
22+
ls -la
23+
docker build . -f Dockerfile -t narmidm/k8s-pod-cpu-stressor:latest
24+
- name: push the docker image
25+
id: push-docker-image
26+
run: docker push ${{vars.DOCKERHUB_USERNAME}}/k8s-pod-cpu-stressor:latest

0 commit comments

Comments
 (0)