Merge pull request #4 from matifali/matlab-dockerhub #61
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 | |
on: | |
schedule: | |
# run every month | |
- cron: "0 0 1 * *" | |
push: | |
branches: [main] | |
paths-ignore: ["**.md"] | |
pull_request: | |
branches: [main] | |
paths-ignore: ["**.md"] | |
workflow_dispatch: | |
concurrency: | |
group: ci-tests-${{ github.ref }}-1 | |
cancel-in-progress: true | |
jobs: | |
build: | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
matifali/matlab | |
tags: | | |
type=raw,value=latest | |
type=raw,value=r2024a | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.title=${{ github.event.repository.name }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
org.opencontainers.image.authors=${{ github.event.repository.owner.login }} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: matifali | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Setup Docker buildx | |
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' | |
uses: docker/setup-buildx-action@v3 | |
- name: Free disk space | |
run: | | |
df -h | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /usr/local/share/chromium | |
sudo rm -rf /usr/local/share/powershell | |
df -h | |
- name: Build and push Docker image | |
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' | |
id: build-and-push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# use gha cache to speed up the build | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Setup Depot | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
uses: depot/setup-action@v1 | |
- name: Build and Push with Depot.dev | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
uses: depot/build-push-action@v1 | |
with: | |
project: z5gr2wjp1s | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |