Skip to content

Commit

Permalink
Update publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
danilonovaisv authored Feb 4, 2025
1 parent bf25a61 commit 78a1331
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,77 +31,93 @@ 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
with:
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
with:
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 }}

0 comments on commit 78a1331

Please sign in to comment.