Skip to content

Commit

Permalink
test new script docker-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Oslan17 committed Sep 11, 2024
1 parent c720d82 commit 4ed0e05
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Push Docker Image to Docker Hub
name: Publish Docker image

on:
push:
Expand All @@ -7,33 +7,22 @@ on:
branches: [ "dev", "main" ]

env:
# Use docker.io for Docker Hub if empty
# Define the Docker Hub namespace and image repository
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: ${{ github.repository }} # Esto usa el formato <usuario>/<repositorio>

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Build the Docker image
run: docker build --no-cache --force-rm ./

push_to_registry:
needs: build
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand All @@ -48,9 +37,18 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit 4ed0e05

Please sign in to comment.