Skip to content

Merge pull request #400 from amirhasanpour/design-patterns #65

Merge pull request #400 from amirhasanpour/design-patterns

Merge pull request #400 from amirhasanpour/design-patterns #65

Workflow file for this run

name: Build and Publish Book Image
on:
push:
branches: ['main']
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Write temporary Dockerfile
run: |
cat <<EOF > Dockerfile
FROM nginx:alpine
LABEL maintainer="Ja7ad <[email protected]>"
LABEL description="GoFarsi book offline in docker"
LABEL org.opencontainers.image.source https://github.com/GoFarsi/book
RUN apk add --no-cache git
RUN git clone https://github.com/GoFarsi/book && cd book && git checkout gh-pages
WORKDIR /book
RUN cp -r . /usr/share/nginx/html
EOF
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/gofarsi/book:latest
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/gofarsi/book
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true