Merge pull request #73 from elementh/feature/tesla-sergius #149
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: Build & Publish | |
on: | |
pull_request: | |
branches: [ main ] | |
push: | |
branches: [ main ] | |
release: | |
types: | |
- published | |
env: | |
# Stop wasting time caching packages / Disable sending usage data to Microsoft | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
- name: Restore | |
working-directory: ./src | |
run: dotnet restore | |
- name: Build | |
working-directory: ./src | |
run: dotnet build --no-restore | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
- name: Restore | |
working-directory: ./src | |
run: dotnet restore | |
- name: Test | |
working-directory: ./src | |
run: dotnet test --verbosity normal --no-restore | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_REPO: elementh | |
IMAGE_NAME: foscbot | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./src/ | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
BOT_VERSION=${{ github.sha }} |