I'm using github actions to deploy my projects on my windows server using FTP
name: .NET
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v3
- name: Setup .NET
uses: actions/setup-dotnet#v2
with:
dotnet-version: 6.0.x
- name: Init Utilities
run: git submodule update --init
- name: Get Utilities
run: git submodule update --remote -f
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Publish
run: dotnet publish
- name: Deploy
uses: SamKirkland/FTP-Deploy-Action#4.0.0
with:
local-dir: LOCAL_DIR
server: SERVER
username: USERNAME
password: PASSWORD
dangerous-clean-slate: true
the problem is that I have to manually stop the server so the files could be uploaded.
but I don't want to stop the server manually. is there any way so I can force update the project without stoping the server or stop the server automatically?
You can add app_offline.htm to make your site offline. When publishing is complete, delete the app_offline.htm file.
Official doc: Taking Web Applications Offline with Web Deploy
You can refer the link to add app_offline.htm file when you delpoy the app.
Related
I'm tasked to automate a dotnet build and deployment process on GitHub. Earlier the engineers were manually building the solution on VScode and didn't face this issue.
Here's the Error screenshot: Build Error Screenshot
Here's my workflow file:
name: Build_Artifacts_Pipeline
on:
push:
branches:
- 'cs1_pipeline_test'
jobs:
build_artifacts:
runs-on: [windows-2019]
steps:
- name: pre-checkout
run:
git config --system core.longpaths true
- name: checkout repo
uses: actions/checkout#v3
- name: Setup MSBuild
uses: microsoft/setup-msbuild#v1.1
with:
vs-version: '15.0'
- name: Create a deploy folder
run: |
cd
mkdir D:\a\CS\Deploy_Reports
- name: Setup dotnet
uses: actions/setup-dotnet#v2
with:
dotnet-version: '5.0'
DOTNET_NOLOGO: 'true'
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
- name: Setup NuGet
uses: Nuget/setup-nuget#v1
with:
nuget-version: '6.0.2'
- name: Cache NuGet Packages
uses: actions/cache#v1
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# - name: NuGet Restore
# if: steps.cache.outputs.cache-hit != 'true'
# run: nuget restore ./WBC.sln
- name: Build Dotnet Framework Project
run: |
nuget install ./WBC.UI.Reporting.Web/packages.config -Source http://nuget.org/api/v2
msbuild ./WBC.UI.Reporting.Web/WBC.UI.Reporting.Web.csproj /p:GenerateSerializationAssemblies=Off /t:Build /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=NewProfile.pubxml /p:OutDir=D:\a\CS\Deploy_Reports\
Here's my csproj: .csproj
name: CI
# 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" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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
- uses: actions/checkout#v2
# Runs a single command using the runners shell
- name: terratest
run: echo Github pat token is ${{ secrets.TF_GITHUB_PAT }}
- name: checkout t2form-k8s repo
uses: actions/checkout#v2
with:
repository: harikalyank/t2form-k8s
token: ${{ secrets.TF_GITHUB_PAT }}
ref: master
The above one is my GH-workflow and it's getting failed to clone repo:t2form-k8s.
error: Warning: The save-state command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Error: Input required and not supplied: token
I created Pat/secret token as well on repository level with name:TF_GITHUB_PAT
I like to test the mail functionally from a WordPress plugin via a Github Workflow and Sendria (MailTrap)
This is my working workflow:
# Based on https://github.com/wp-cli/scaffold-command/blob/f9bad3dd7224d5684d950d31c486df70905e386f/templates/plugin-github.mustache
name: WordPress Test
on: [push]
env:
WP_TESTS_DIR: /github/home/wp-tests/wordpress-tests-lib
WP_CORE_DIR: /github/home/wp-tests/wordpress
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [7.2]
wordpress-version: [latest]
container:
image: junaidbhura/wp-tests:php-${{ matrix.php-version }}
services:
mysql:
image: mysql:5.7.27
env:
MYSQL_ROOT_PASSWORD: root
steps:
- name: Checkout repository
uses: actions/checkout#v1
- name: Install Composer dependencies
run: |
composer install --no-dev
composer global require "phpunit/phpunit=6.1.0"
composer global require "yoast/phpunit-polyfills=1.0.3"
- name: Install WordPress test suite
run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wordpress-version }}
- name: Tests
run: $HOME/.composer/vendor/bin/phpunit --config=phpunit-integration.xml
This workflow
checkout my plugin
install composer dependencies
install the WordPress test suite
run the Tests (which should contain mail tests)
Now I like to add Sendria to this flow by adding this action right above the first step:
- name: Start Sendira
uses: upgundecha/start-sendria-github-action#v1.0.0
with:
smtp-port: 1025
http-port: 1080
To test that Sendria is running I check the endpoint via curl with an additional step:
- name: Test
run: |
curl -LI http://127.0.0.1:1080
And this "Test" fails:
I tried the workflow locally with act where this step worked but have no idea how to get this working on Github.
I've also created a test repo on Github here.
In my server, if I run
sudo ./svc.sh status
I got this
It says status is active. But Runner listener exited with error code null
In my, Github accounts actions page runner is offline.
The runner should be Idle as far as I know.
This is my workflow
name: Node.js CI
on:
push:
branches: [ dev ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [ 12.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
Here I don't have any build scripts because I directly push the build folder to Github repo.
How do I fix this error?
I ran into this issue when I first installed the runner application under $USER1 but configured it as a service when I was $USER2.
In the end, I ran cd /home/$USER1/actions-runner && sudo ./svc.sh uninstall to remove the service.
Changed the owner of the all files in the /home/$USER1/actions-runner/ by
sudo chown -R $USER2 /home/$USER1/actions-runner.
And ran ./config.sh remove --token $HASHNUBER (you can get this by following this page) to removed all the runner application.
I also removed it from github settings runner page.
In the end, I installed eveything again as the same user, and it worked out.
I ran into this same issue and it turned out to be a disk space problem. Make sure your server has enough allocated storage.
I am working on the .NET Core solution below:
and I am using the Gitlab CI definition below:
.gitlab-ci.yml:
image: docker:stable
services:
- docker:dind
stages:
- test
- build
- deploy-db
- deploy
variables:
DOCKER_REGISTRY: "our.registry.eu"
IMAGE_NAME: "${DOCKER_REGISTRY}/membercreditor"
# secrets are on GitLab environment variables (settings > ci/cd)
RANCHER_ENV: 1a10
RANCHER_STACK: api
RANCHER_SVC: membercreditor
RANCHER_DEV_KEY: a dev key
RANCHER_DEV_URL: http://our.dev.rancher.io:8080
RANCHER_PREPROD_KEY: a preprod key
RANCHER_PREPROD_URL: http://our.preprod.rancher.io:8080
RANCHER_PROD_KEY: a prod key
RANCHER_PROD_URL: http://our.prod.rancher.io:8080
.test:
stage: test
image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
script:
- dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
- dotnet test ./Rm.MemberCreditor.Domain.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Api.Tests/TestResults/coverage.json
- dotnet test ./Rm.MemberCreditor.IntegrationTests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Domain.Tests/TestResults/coverage.json
coverage: '/Total[ |]+(\d+[,.]\d+)%/'
artifacts:
reports:
junit: ./*.Tests/TestResults/*.xml
.build:
stage: build
tags:
- dind
script:
- docker build -t $IMAGE_NAME:$APP_VERSION -f Dockerfile .
- docker login $DOCKER_REGISTRY -u svc_finance_revmgt -p $SVC_FINANCE_REVMGT_TOKEN
- docker push $IMAGE_NAME:$APP_VERSION
.deploy-db:
stage: deploy-db
image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
script:
- export CONNECTIONSTRINGS__MEMBERCREDITOR=$CONNECTIONSTRINGS__MEMBERCREDITOR
- export SECRETS__CS_MEMBERCREDITOR=$SECRETS__CS_MEMBERCREDITOR
- dotnet tool restore
- dotnet ef database update -p ./Rm.MemberCreditor.Data.Migrations -s ./Rm.MemberCreditor.Api -v
.deploy:
stage: deploy
image: cdrx/rancher-gitlab-deploy
script:
- upgrade --rancher-key $RANCHER_KEY
--rancher-secret $RANCHER_SECRET
--rancher-url $RANCHER_URL
--environment $RANCHER_ENV
--stack $RANCHER_STACK
--service $RANCHER_SVC
--new-image $IMAGE_NAME:$APP_VERSION
###########################
### Merge Requests
###########################
test-merge-request:
extends: .test
only:
refs:
- merge_requests
###########################
### Integration
###########################
test-integration:
extends: .test
environment:
name: integration
only:
- develop
build-integration:
extends: .build
environment:
name: integration
dependencies:
- test-integration
before_script:
- APP_VERSION=latest-integration
only:
- develop
deploy-db-integration:
extends: .deploy-db
environment:
name: integration
dependencies:
- build-integration
before_script:
- export ASPNETCORE_ENVIRONMENT=Integration
only:
- develop
deploy-integration:
extends: .deploy
environment:
name: integration
dependencies:
- deploy-db-integration
before_script:
- APP_VERSION=latest-integration
- RANCHER_KEY=$RANCHER_DEV_KEY
- RANCHER_SECRET=$RANCHER_DEV_SECRET
- RANCHER_URL=$RANCHER_DEV_URL
only:
- develop
###########################
### UAT
###########################
test-uat:
extends: .test
environment:
name: uat
only:
- master
build-uat:
extends: .build
environment:
name: uat
dependencies:
- test-uat
before_script:
- APP_VERSION=latest-uat
only:
- master
deploy-db-uat:
extends: .deploy-db
environment:
name: uat
dependencies:
- build-uat
before_script:
- export ASPNETCORE_ENVIRONMENT=Uat
only:
- master
deploy-uat:
extends: .deploy
environment:
name: uat
dependencies:
- deploy-db-uat
before_script:
- APP_VERSION=latest-uat
- RANCHER_KEY=$RANCHER_PREPROD_KEY
- RANCHER_SECRET=$RANCHER_PREPROD_SECRET
- RANCHER_URL=$RANCHER_PREPROD_URL
only:
- master
###########################
### Production
###########################
build-prod:
extends: .build
environment:
name: production
before_script:
- APP_VERSION=$CI_COMMIT_TAG
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
deploy-db-prod:
extends: .deploy-db
environment:
name: production
dependencies:
- build-prod
before_script:
- export ASPNETCORE_ENVIRONMENT=Production
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
deploy-prod:
extends: .deploy
environment:
name: production
when: manual
dependencies:
- deploy-db-prod
before_script:
- APP_VERSION=$CI_COMMIT_TAG
- RANCHER_KEY=$RANCHER_PROD_KEY
- RANCHER_SECRET=$RANCHER_PROD_SECRET
- RANCHER_URL=$RANCHER_PROD_URL
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
When the Gitlab is running the test-merge-request, I am getting the error below:
Fetching changes with git depth set to 50...
00:02
Initialized empty Git repository in /builds/finance/products/revenuemgmt/modules/membercreditor/.git/
Created fresh repository.
From https://our.org/finance/products/revenuemgmt/modules/membercreditor
* [new ref] refs/merge-requests/38/head -> refs/merge-requests/38/head
* [new ref] refs/pipelines/355543 -> refs/pipelines/355543
Checking out 603e9a2c as refs/merge-requests/38/head...
Skipping Git submodules setup
$ dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
00:12
FSC : error FS0078: Unable to find the file 'Legacy/Queries/GetOrderRelatedInfoForAccountingEntryCreation.sql' in any of /builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data [/builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data/Rm.MemberCreditor.Data.fsproj]
Uploading artifacts...
00:02
WARNING: ./*.Tests/TestResults/*.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
GetOrderRelatedInfoForAccountingEntryCreation.sql is defined as an embedded resource, I tried to force to copy the file to the output but I still am getting the same very same error.
I am not sure why this post has been down-voted, but fun fact, seems there is a bug in Rider 2019.3.1.
The issue arose because even though the file was showing up as GetOrderRelatedInfoForAccountingEntryCreation.sql in Rider aka pascal case it was actually written as a camel case (i.e. getOrderRelatedInfoForAccountingEntryCreation.sql) on the disk, go figure.
Once the name adjusted to pascal for the actual file on the disk, everything worked fine.