Merge pull request #398 from GoFarsi/imgbot #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |