Отсортировать настройки взноса в правильном порядке (#2924) #2558
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 and publish | |
on: | |
pull_request: | |
merge_group: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
tags: | |
- v** | |
workflow_dispatch: | |
env: | |
APP_NAME: joinrpg-portal | |
MIGRATOR_NAME: joinrpg-dal-migrate | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
jobs: | |
build: | |
name: Build and publish | |
runs-on: ubuntu-20.04 | |
permissions: | |
packages: write | |
checks: write | |
actions: write | |
statuses: write | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch the whole repo history | |
# TODO: Make GitHub Action from this script | |
- name: Git Version # Fills env.CALCULATED_VERSION and env.CALCULATED_VERSION_IS_RELEASE | |
id: version | |
run: iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/AntonSmolkov/HandyPoshScripts/v1.0.2/DevOps/SemVerCalc_GitHubFlow_Actions.ps1')) | |
shell: pwsh | |
env: | |
REF_NAME: ${{ github.ref_name }} | |
REF_TYPE: ${{ github.ref_type }} | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4.1.0 | |
with: | |
global-json-file: global.json | |
- name: Restore nuget dependencies cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget | |
#temporary disable docker cache | |
# - name: Restore docker images cache | |
# uses: satackey/action-docker-layer-caching@v0.0.11 | |
# continue-on-error: true | |
- name: Restore | |
run: dotnet restore | |
- name: Format | |
run: dotnet format --no-restore --verify-no-changes --severity error | |
- name: Build | |
run: dotnet build -c Release --property:Version=${{ env.CALCULATED_VERSION }} | |
# run: dotnet build -c Release --no-restore | |
- name: Test | |
run: dotnet test -c Release --no-build --logger trx --results-directory ./TestResults | |
- name: Save test results to artifacts | |
uses: actions/upload-artifact@v4 # upload test results | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: test-results | |
path: TestResults | |
#Rest of the pipeline implies write api privileges and can't be run on PRs | |
- name: Publish portal | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: dotnet publish -c Release --no-build ./src/JoinRpg.Portal/JoinRpg.Portal.csproj -p:Version=${{ env.CALCULATED_VERSION }} | |
- name: Publish migrator | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: dotnet publish -c Release --no-build ./src/Joinrpg.Dal.Migrate/Joinrpg.Dal.Migrate.csproj -p:Version=${{ env.CALCULATED_VERSION }} | |
- name: Build portal image | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: docker build ./src/JoinRpg.Portal --tag ${APP_NAME} --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Build migrator image | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: docker build ./src/Joinrpg.Dal.Migrate --tag ${MIGRATOR_NAME} --label "runnumber=${GITHUB_RUN_ID}" | |
- name: Log in to docker registry | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Push portal image to docker registry | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: | | |
APP_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${APP_NAME} | |
# Change all uppercase to lowercase | |
APP_IMAGE_ID=$(echo ${APP_IMAGE_ID} | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo ${{ env.CALCULATED_VERSION }} | tr '[A-Z]' '[a-z]') | |
docker tag ${APP_NAME} ${APP_IMAGE_ID}:${VERSION} | |
docker push ${APP_IMAGE_ID}:${VERSION} | |
if [[ "${{ env.CALCULATED_VERSION_IS_RELEASE }}" == "True" ]] | |
then | |
docker tag ${APP_NAME} ${APP_IMAGE_ID}:latest | |
docker push ${APP_IMAGE_ID}:latest | |
fi | |
- name: Push migrator image to docker registry | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' | |
run: | | |
MIGRATOR_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${MIGRATOR_NAME} | |
# Change all uppercase to lowercase | |
MIGRATOR_IMAGE_ID=$(echo ${MIGRATOR_IMAGE_ID} | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo ${{ env.CALCULATED_VERSION }} | tr '[A-Z]' '[a-z]') | |
docker tag ${MIGRATOR_NAME} ${MIGRATOR_IMAGE_ID}:${VERSION} | |
docker push ${MIGRATOR_IMAGE_ID}:${VERSION} | |
if [[ "${{ env.CALCULATED_VERSION_IS_RELEASE }}" == "True" ]] | |
then | |
docker tag ${MIGRATOR_NAME} ${MIGRATOR_IMAGE_ID}:latest | |
docker push ${MIGRATOR_IMAGE_ID}:latest | |
fi |