Build #896
This file contains 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 | |
concurrency: build | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- Dockerfile | |
- entrypoint.sh | |
- .github/workflows/build.yml | |
pull_request: | |
branches: | |
- main | |
paths: | |
- Dockerfile | |
- entrypoint.sh | |
schedule: | |
- cron: '0 0 * * *' | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
permissions: | |
packages: read | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log into GitHub container registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Pull latest image | |
run: docker pull ghcr.io/${IMAGE_NAME}:latest || true | |
- name: Build image | |
uses: docker/[email protected] | |
with: | |
pull: true | |
push: false | |
cache-from: ghcr.io/${{ env.IMAGE_NAME }}:latest | |
tags: ghcr.io/${{ env.IMAGE_NAME }}:ci | |
outputs: type=docker,dest=/tmp/image.tar | |
- name: Upload image archive | |
uses: actions/upload-artifact@v4 | |
if: github.ref == 'refs/heads/main' | |
with: | |
name: docker-image | |
path: /tmp/image.tar | |
publish: | |
name: Publish Image | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
registry: | |
- ghcr.io | |
- docker.io | |
include: | |
- registry: ghcr.io | |
secret: GITHUB_TOKEN | |
- registry: docker.io | |
secret: DOCKER_TOKEN | |
steps: | |
- name: Download image archive | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker-image | |
path: /tmp/ | |
- name: Import image | |
run: docker load --input /tmp/image.tar | |
- name: Log into Docker registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ matrix.registry }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets[matrix.secret] }} | |
logout: true | |
- name: Tag image with latest tag | |
run: docker tag ghcr.io/${IMAGE_NAME}:ci ${{ matrix.registry }}/${IMAGE_NAME}:latest | |
- name: Push image to container registry | |
run: docker push ${{ matrix.registry }}/${IMAGE_NAME}:latest |