Skip to content

fix build

fix build #71

Workflow file for this run

name: dotnet package
on: [push]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
ports:
- 54321:5432
env:
POSTGRES_PASSWORD: example
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
- name: Test with dotnet
run: dotnet test --no-restore --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: networking-bot-tests-results
path: TestResults
if: ${{ always() }}
- name: Package bot
run: dotnet publish NetworkingBot/NetworkingBot.csproj --no-restore --no-build -o build/ -c Release /p:UseAppHost=false
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: networking-bot
path: build
# package:
# runs-on: ubuntu-latest
# if: startsWith(github.event.ref, 'refs/tags/networking-bot-')
# needs: build
# steps:
# - uses: actions/checkout@v4
# - name: Set Version
# run: echo "BOT_VERSION=${GITHUB_REF#refs/tags/networking-bot-}" >> $GITHUB_ENV
# - name: Login to Yandex Cloud Container Registry
# id: login-cr
# uses: yc-actions/yc-cr-login@v3
# with:
# yc-sa-json-credentials: ${{ secrets.YC_CONTAINER_REGISTRY_CREDENTIALS }}
# - uses: actions/download-artifact@v4
# with:
# name: networking-bot
# path: build
# - name: Build, tag, and push image to Yandex Cloud Container Registry
# env:
# CR_REGISTRY: ${{ secrets.YC_CONTAINER_REGISTRY }}
# CR_REPOSITORY: networking-bot
# IMAGE_TAG: ${{ env.BOT_VERSION }}
# run: |
# docker build -f NetworkingBot/Dockerfile build -t cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
# docker push cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
package-docker-hub:
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/networking-bot-')
needs: build
steps:
- uses: actions/checkout@v4
- name: Set Version
run: echo "BOT_VERSION=${GITHUB_REF#refs/tags/networking-bot-}" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/download-artifact@v4
with:
name: networking-bot
path: build
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./NetworkingBot/Dockerfile
push: true
tags: holyslon/networking-bot:latest
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: index.docker.io/holyslon/networking-bot
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
# verify-tf:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: ./iac
# steps:
# - name: Checkout the repository to the runner
# uses: actions/checkout@v4
#
# - name: Setup Tf Repos
# run: |
# cat <<EOF >>~/.terraformrc
# provider_installation {
# network_mirror {
# url = "https://terraform-mirror.yandexcloud.net/"
# include = ["registry.terraform.io/*/*"]
# }
# direct {
# exclude = ["registry.terraform.io/*/*"]
# }
# }
# EOF
# - name: Setup Tf State config
# env:
# ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
# SECRET_KEY: ${{ secrets.SECRET_KEY }}
# run: |
# cat <<EOF >config.s3.tfbackend
# access_key="$ACCESS_KEY"
# secret_key="$SECRET_KEY"
# EOF
#
# - name: Setup Tf Api Key
# env:
# YC_KEY: ${{ secrets.YC_KEY }}
# run: echo "$YC_KEY" > key.json
#
#
# - name: Setup Terraform with specified version on the runner
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.8.5
#
# - name: Terraform init
# id: init
# run: terraform init -backend-config=config.s3.tfbackend
#
# - name: Terraform format
# id: fmt
# run: terraform fmt -check -diff
#
# - name: Terraform validate
# id: validate
# run: terraform validate
#
# plan-tf:
# runs-on: ubuntu-latest
# if: startsWith(github.event.ref, 'refs/tags/networking-bot-')
# needs:
# - package
# - verify-tf
# defaults:
# run:
# working-directory: ./iac
# steps:
# - name: Checkout the repository to the runner
# uses: actions/checkout@v4
#
# - name: Setup Tf Repos
# run: |
# cat <<EOF >>~/.terraformrc
# provider_installation {
# network_mirror {
# url = "https://terraform-mirror.yandexcloud.net/"
# include = ["registry.terraform.io/*/*"]
# }
# direct {
# exclude = ["registry.terraform.io/*/*"]
# }
# }
# EOF
# - name: Setup Tf State config
# env:
# ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
# SECRET_KEY: ${{ secrets.SECRET_KEY }}
# run: |
# cat <<EOF >config.s3.tfbackend
# access_key="$ACCESS_KEY"
# secret_key="$SECRET_KEY"
# EOF
#
# - name: Setup Tf Api Key
# env:
# YC_KEY: ${{ secrets.YC_KEY }}
# run: echo "$YC_KEY" > key.json
#
#
# - name: Setup Terraform with specified version on the runner
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.8.5
#
# - name: Terraform init
# id: init
# run: terraform init -backend-config=config.s3.tfbackend
#
# - name: Set Version
# run: echo "BOT_VERSION=${GITHUB_REF#refs/tags/networking-bot-}" >> $GITHUB_ENV
#
# - name: Terraform plan
# id: plan
# env:
# BOT_VERSION: ${{ env.BOT_VERSION }}
# TELEGRAM_API_KEY: ${{ secrets.TELEGRAM_API_KEY }}
# run: terraform plan -no-color -input=false -var="app_version=$BOT_VERSION" -var="telegram_api_key=$TELEGRAM_API_KEY" -out="./planfile"
# continue-on-error: true
#
# - name: Upload plan
# uses: actions/upload-artifact@v4
# with:
# include-hidden-files: 'true'
# name: networking-bot-planfile
# path: ./iac/planfile
# apply-tf:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: ./iac
# if: startsWith(github.event.ref, 'refs/tags/networking-bot-')
# needs:
# - package
# - verify-tf
# - plan-tf
# steps:
# - name: Checkout the repository to the runner
# uses: actions/checkout@v4
#
# - name: Setup Tf Repos
# run: |
# cat <<EOF >>~/.terraformrc
# provider_installation {
# network_mirror {
# url = "https://terraform-mirror.yandexcloud.net/"
# include = ["registry.terraform.io/*/*"]
# }
# direct {
# exclude = ["registry.terraform.io/*/*"]
# }
# }
# EOF
# - name: Setup Tf State config
# env:
# ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
# SECRET_KEY: ${{ secrets.SECRET_KEY }}
# run: |
# cat <<EOF >config.s3.tfbackend
# access_key="$ACCESS_KEY"
# secret_key="$SECRET_KEY"
# EOF
#
# - name: Setup Tf Api Key
# env:
# YC_KEY: ${{ secrets.YC_KEY }}
# run: echo "$YC_KEY" > key.json
#
# - uses: actions/download-artifact@v4
# with:
# name: networking-bot-planfile
# path: ./iac/plan
#
# - name: Setup Terraform with specified version on the runner
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.8.5
#
# - name: Terraform init
# id: init
# run: terraform init -backend-config=config.s3.tfbackend
#
# - name: Set Version
# run: echo "BOT_VERSION=${GITHUB_REF#refs/tags/networking-bot-}" >> $GITHUB_ENV
#
# - name: Terraform apply
# id: plan
# run: terraform apply -auto-approve "./plan/planfile"