ci: add deployment workflow for artifact delivery (#103)

- Add a deployment job to the CI workflow
- Upload `world.txt` as an artifact
- Download the artifact to the `distfiles` directory
- Add a step to copy files to a server using SSH

fix https://github.com/appleboy/scp-action/issues/35
This commit is contained in:
Bo-Yi Wu 2023-04-09 16:49:19 +08:00 committed by GitHub
parent d47875703f
commit c8e0cef94a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 2 deletions

View file

@ -2,8 +2,8 @@ name: scp files
on: [push]
jobs:
build:
name: Build
testing:
name: test scp action
runs-on: ubuntu-latest
steps:
- name: checkout
@ -62,3 +62,32 @@ jobs:
source: "tests/a.txt,tests/b.txt"
target: "test"
use_insecure_cipher: true
deploy:
name: deploy artifact
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- run: echo hello > world.txt
- uses: actions/upload-artifact@v3
with:
name: my-artifact
path: world.txt
- uses: actions/download-artifact@v2
with:
name: my-artifact
path: distfiles
- name: copy file to server
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: distfiles/*
target: test

View file

@ -203,6 +203,39 @@ Example configuration for exclude custom files:
target: "test"
```
Upload artifact files to remote server:
```yaml
deploy:
name: deploy artifact
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- run: echo hello > world.txt
- uses: actions/upload-artifact@v3
with:
name: my-artifact
path: world.txt
- uses: actions/download-artifact@v2
with:
name: my-artifact
path: distfiles
- name: copy file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: distfiles/*
target: test
```
Remove the specified number of leading path elements:
```yaml