Skip to content

Commit

Permalink
Update docker-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani authored Jan 26, 2025
1 parent f279e16 commit 293f756
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,43 @@ on:
branches: [ master ]

jobs:
build:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
# required pre-steps for docker + cache
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: sipcapture/hepop

# establish the docker tag to use
- name: Prepare
id: prep
run: |
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g')
TAG="$(echo -e "${PACKAGE_VERSION}-$(date +%s)" | tr -d '[:space:]')"
echo ::set-output name=version::${TAG}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build wihtout push
uses: docker/build-push-action@v2
with:
file: ./docker/Dockerfile
tags: sipcapture/hepop:${{ steps.prep.outputs.version }}
push: false
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit 293f756

Please sign in to comment.