flam-flam/dispatcher-service#21 add more fields #40
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: CI | |
on: | |
push: | |
paths-ignore: | |
- README.md | |
- .gitignore | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository_owner }}/submission | |
USE_DOTNET_VERSION: '7.0.x' | |
WORKING_DIRECTORY_PATH: 'src' | |
DOCKER_BUILD_CONTEXT: './src/flamflam.SubmissionService' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.USE_DOTNET_VERSION }} | |
- name: Install dependencies | |
run: dotnet restore | |
working-directory: ${{ env.WORKING_DIRECTORY_PATH }} | |
- name: Test with the dotnet CLI | |
run: dotnet test | |
working-directory: ${{ env.WORKING_DIRECTORY_PATH }} | |
version: | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
permissions: | |
contents: write | |
outputs: | |
version_resolved: ${{ steps.resolve_version.outputs.version_resolved }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Tag and use it as version | |
if: github.ref == 'refs/heads/main' | |
uses: anothrNick/github-tag-action@8c8163ef62cf9c4677c8e800f36270af27930f42 # 1.61.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG_CONTEXT: branch | |
PRERELEASE: ${{ github.ref != 'refs/heads/main' }} | |
- uses: actions-ecosystem/action-get-latest-tag@b7c32daec3395a9616f88548363a42652b22d435 # v1.6.0 | |
id: version_latest_tag | |
if: github.ref == 'refs/heads/main' | |
- name: Use branch name as version | |
if: github.ref != 'refs/heads/main' | |
id: version_branch_name | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
echo "Branch name: $BRANCH_NAME" | |
echo "branch_name=${BRANCH_NAME//\//_}" >> $GITHUB_OUTPUT | |
- name: Output resolved version | |
id: resolve_version | |
run: | | |
if [ -n "${{ steps.version_latest_tag.outputs.tag }}" ]; then | |
echo "version_resolved=${{ steps.version_latest_tag.outputs.tag }}" >> $GITHUB_OUTPUT | |
else | |
echo "version_resolved=${{ steps.version_branch_name.outputs.branch_name }}" >> $GITHUB_OUTPUT | |
fi | |
build: | |
needs: | |
- version | |
permissions: | |
packages: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
- name: Login to GitHub 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@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push image tag ${{ needs.version.outputs.version_resolved }} | |
env: | |
RESOLVED_VERSION: ${{needs.version.outputs.version_resolved}} | |
uses: docker/build-push-action@v3 | |
with: | |
context: ${{ env.DOCKER_BUILD_CONTEXT }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RESOLVED_VERSION }} | |
- name: Build and push 'latest' tag | |
uses: docker/build-push-action@v3 | |
with: | |
context: ${{ env.DOCKER_BUILD_CONTEXT }} | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' }} | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |