From 78a13318ed502ad1db899a92460c8ee2afd754cf Mon Sep 17 00:00:00 2001 From: Danilo Novais <140909356+danilonovaisv@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:46:25 -0300 Subject: [PATCH] Update publish.yml --- .github/workflows/publish.yml | 60 +++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1515f378eb..a0ff8cdf06 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,11 +10,15 @@ on: paths: - 'base/publish/*' schedule: - - cron: '0 0 * * 2' + - cron: '0 0 * * 2' workflow_dispatch: name: Publish Debian & Ubuntu Base Images +env: + REGISTRY: ghcr.io + IMAGE_NAME: railwayapp/nixpacks + jobs: debian: runs-on: ubuntu-latest @@ -27,47 +31,59 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Get current date id: date - run: echo "::set-output name=date::$(date +%s)" - + run: echo "date=$(date +%s)" >> $GITHUB_ENV + - name: Build and push [Debian] uses: docker/build-push-action@v5 with: context: base/debian platforms: linux/arm64, linux/amd64, linux/386 push: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - tags: ghcr.io/railwayapp/nixpacks:debian, ghcr.io/railwayapp/nixpacks:debian-${{ steps.date.outputs.date }} - + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-${{ env.date }} + cache-from: type=gha,scope=${{ github.sha }} + cache-to: type=gha,mode=max,scope=${{ github.sha }} + - name: Build and push [Ubuntu] uses: docker/build-push-action@v5 with: context: base/ubuntu platforms: linux/arm64, linux/amd64 push: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - tags: ghcr.io/railwayapp/nixpacks:ubuntu, ghcr.io/railwayapp/nixpacks:latest, ghcr.io/railwayapp/nixpacks:ubuntu-${{ steps.date.outputs.date }} - + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ubuntu, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ubuntu-${{ env.date }} + cache-from: type=gha,scope=${{ github.sha }} + cache-to: type=gha,mode=max,scope=${{ github.sha }} + - name: Bump base image if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} run: | - sed -i 's/nixpacks:debian-.*/nixpacks:debian-${{ steps.date.outputs.date }}";/g' src/nixpacks/images.rs - sed -i 's/nixpacks:ubuntu-.*/nixpacks:ubuntu-${{ steps.date.outputs.date }}";/g' src/nixpacks/images.rs - + sed -i 's/nixpacks:debian-.*/nixpacks:debian-${{ env.date }}";/g' src/nixpacks/images.rs + sed -i 's/nixpacks:ubuntu-.*/nixpacks:ubuntu-${{ env.date }}";/g' src/nixpacks/images.rs + - name: Create Pull Request if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} uses: peter-evans/create-pull-request@v7 @@ -75,24 +91,26 @@ jobs: base: main token: ${{ secrets.COMMITTER_TOKEN }} commit-message: Bump base image - branch: publish-${{ steps.date.outputs.date }} + branch: publish-${{ env.date }} delete-branch: true - title: Bump base images to `${{ steps.date.outputs.date }}` + title: Bump base images to `${{ env.date }}` labels: release/patch - + - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Build and push to Docker Hub [Debian] uses: docker/build-push-action@v5 with: context: base/debian platforms: linux/arm64, linux/amd64, linux/386 push: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - tags: railwayapp/nixpacks:debian, railwayapp/nixpacks:latest, railwayapp/nixpacks:debian-${{ steps.date.outputs.date }} + tags: railwayapp/nixpacks:debian, railwayapp/nixpacks:latest, railwayapp/nixpacks:debian-${{ env.date }} + cache-from: type=gha,scope=${{ github.sha }} + cache-to: type=gha,mode=max,scope=${{ github.sha }} - name: Build and push to Docker Hub [Ubuntu] uses: docker/build-push-action@v5 @@ -100,4 +118,6 @@ jobs: context: base/ubuntu platforms: linux/arm64, linux/amd64 push: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - tags: railwayapp/nixpacks:ubuntu, railwayapp/nixpacks:ubuntu-${{ steps.date.outputs.date }} + tags: railwayapp/nixpacks:ubuntu, railwayapp/nixpacks:ubuntu-${{ env.date }} + cache-from: type=gha,scope=${{ github.sha }} + cache-to: type=gha,mode=max,scope=${{ github.sha }}