Skip to content

Exempel för dontnet CI-workflow

Github Actions


För VG-delen ( ha version-taggar) Lägg till följande steg efteråt:
__
Grund-delen:
Använd följande GIthub Actions enligt dina secrets ( Repo-settings → Secrets → Actions
bild.png
bild.png
bild.png
bild.png

Tryck in dig på “Actions” i din repo:
bild.png
Skapa ett nytt workflow:
bild.png
Följa en mall eller starta fån grunden.
bild.png
Klistra in denna del som vi satte ihop under lektionen:



name: automation

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]



# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkar in på den aktuella branschen och repon
uses: actions/checkout@v2

# Använder tillfälligt dotnet-miljön
- name: Setup Dotnet Env
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Kör restore
run: dotnet restore
- name: Kör vår Build
run: dotnet build --no-restore
- name: Genomför unit-tester
run: dotnet test --no-build
- name: Loggar in på Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Building the Docker Image och skickar den till Docker Hub
uses: docker/build-push-action@v2.9.0
with:
push: true
tags: ANVÄNDARNAMN_PÅ_DOCKER_HUB/NAMNET_OCH_TAGEN_TILL_DIN_IMAGE
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Tack tack, bra jobbat!


# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.



Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.