Docker Build And Push #27
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: Docker Build And Push | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
check: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: octokit/request-action@v2.x | |
id: check_last_run | |
with: | |
route: GET /repos/${{github.repository}}/actions/workflows/main.yml/runs?per_page=1&status=completed | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: "echo Last daily build: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }}" | |
outputs: | |
last_sha: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }} | |
build: | |
runs-on: ubuntu-latest | |
needs: [check] | |
if: needs.check.outputs.last_sha != github.sha | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build Debian package | |
uses: docker/build-push-action@v5 | |
with: | |
load: true | |
push: false | |
target: builder | |
context: . | |
tags: lego-technic-deb:latest | |
- name: Extract to host | |
uses: shrink/actions-docker-extract@v3 | |
id: extract | |
with: | |
image: lego-technic-deb:latest | |
path: /dist/. | |
destination: ./dist | |
- name: Push to Gemfury | |
run: | | |
debfile=$(find ./dist/*.deb) | |
curl -F package=@$debfile https://${{ secrets.GEMFURY_TOKEN }}@push.fury.io/debilin/ | |
- name: Build Docker Image | |
id: buildAndPushImage | |
uses: MaximilianoBz/dockerhub-buildpush@v1.0 | |
with: | |
registry_url: 'docker.io' | |
repository_name: 'lego-technic' | |
user_name: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
image_version: 'nightly' | |
docker_file: '.' | |
- name: Get pre step result output image_pull_url | |
run: echo "The time was ${{ steps.buildAndPushImage.outputs.image_pull_url }}" |