From bcda430a1ea84b0f178bf81812c8cf1dab26984b Mon Sep 17 00:00:00 2001 From: Goncalo Oliveira Date: Thu, 15 Jun 2023 17:42:30 +0100 Subject: [PATCH] added workflow templates --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++ .github/workflows/publish.yml | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..26ed967 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Build and Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + + permissions: + packages: read + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + source-url: https://nuget.pkg.github.com/justfaas/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Restore dependencies + run: dotnet restore src + - name: Build + run: dotnet build --no-restore src + # - name: Test + # run: dotnet test --no-build --verbosity normal tests diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ce1e78a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: Publish + +on: + push: + tags: [ "v*" ] + +jobs: + publish: + + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: prep + run: | + DOCKER_IMAGE=ghcr.io/justfaas/idler + VERSION=${GITHUB_REF#refs/tags/} + VERSION=${VERSION#v} + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "tags=${TAGS}" >> $GITHUB_OUTPUT + - name: Build and push Docker image + id: docker_build + uses: docker/build-push-action@v4 + with: + push: true + tags: ${{ steps.prep.outputs.tags }} + platforms: linux/amd64,linux/arm64 + secrets: | + GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + draft: true + tag_name: ${{ github.ref_name }} + generate_release_notes: true + token: ${{ secrets.GITHUB_TOKEN }}