-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- 'README.md' | ||
- 'LICENSE' | ||
- '.github/**' | ||
- '!.github/workflows/build.yml' | ||
push: | ||
branches: | ||
- main | ||
tags: '[0-9]+.[0-9]+.[0-9]+' | ||
paths-ignore: | ||
- 'README.md' | ||
- 'LICENSE' | ||
- '.github/**' | ||
- '!.github/workflows/build.yml' | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
docker: | ||
name: Build and Push Docker Image | ||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ls1intum/Pyris' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Compute Tag | ||
uses: actions/github-script@v6 | ||
id: compute-tag | ||
with: | ||
result-encoding: string | ||
script: | | ||
if (context.eventName === "pull_request") { | ||
return "pr-" + context.issue.number; | ||
} | ||
if (context.eventName === "release") { | ||
return "latest"; | ||
} | ||
if (context.eventName === "push") { | ||
if (context.ref.startsWith("refs/tags/")) { | ||
return context.ref.slice(10); | ||
} | ||
if (context.ref === "refs/heads/main") { | ||
return "latest"; | ||
} | ||
} | ||
return "FALSE"; | ||
- uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
# Build and Push to GitHub Container Registry | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
if: ${{ steps.compute-tag.outputs.result != 'FALSE' }} | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and Push to GitHub Container Registry | ||
uses: docker/build-push-action@v4 | ||
if: ${{ steps.compute-tag.outputs.result != 'FALSE' }} | ||
with: | ||
platforms: amd64, arm64 | ||
file: ./Dockerfile | ||
context: . | ||
tags: ghcr.io/ls1intum/pyris:${{ steps.compute-tag.outputs.result }} | ||
push: true |