Skip to content

Commit 8273b1c

Browse files
authored
Update workflow.yaml
1 parent 85da9d9 commit 8273b1c

1 file changed

Lines changed: 67 additions & 35 deletions

File tree

.github/workflows/workflow.yaml

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,73 @@ on:
99

1010
jobs:
1111
build:
12-
#runs-on: ubuntu-latest
1312
runs-on: arc-runner-set
14-
13+
1514
steps:
16-
- uses: actions/checkout@v1
17-
- name: Setup .NET Core
18-
uses: actions/setup-dotnet@v1
15+
-
16+
name: set output
17+
run: |
18+
echo "run_id=${{github.run_id}}.${{ github.run_attempt }}" >> "$GITHUB_ENV"
19+
20+
- uses: actions/checkout@v4
21+
22+
#-
23+
# name: Set up QEMU
24+
# uses: docker/setup-qemu-action@v3
25+
26+
-
27+
name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
with:
30+
platforms: linux/amd64
31+
32+
-
33+
name: Login to private registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ secrets.REGISTRY_URL }}
37+
username: ${{ secrets.REGISTRY_USERNAME }}
38+
password: ${{ secrets.REGISTRY_PASSWORD }}
39+
40+
-
41+
name: Build and push
42+
uses: docker/build-push-action@v6
1943
with:
20-
dotnet-version: '8.0.x'
21-
- name: Dotnet Publish
22-
run: dotnet publish ReDocSample -c Release -o deploy
23-
# - name: Stop Service
24-
# uses: garygrossgarten/github-action-ssh@0.7.0
25-
# with:
26-
# command: |
27-
# sudo systemctl stop redoc.service
28-
# host: ${{ secrets.REMOTE_HOST }}
29-
# username: ${{ secrets.REMOTE_USER }}
30-
# privatekey: ${{ secrets.REMOTE_SSH_KEY }}
31-
# - name: deploy file
32-
# uses: wlixcc/SFTP-Deploy-Action@v1.2.4
33-
# with:
34-
# username: ${{ secrets.REMOTE_USER }}
35-
# server: ${{ secrets.REMOTE_HOST }}
36-
# ssh_private_key: ${{ secrets.REMOTE_SSH_KEY }}
37-
# local_path: './deploy/*'
38-
# remote_path: ${{ secrets.REMOTE_TARGET }}
39-
# sftpArgs: '-o ConnectTimeout=5'
40-
# - name: Restart Nginx and Start Service
41-
# uses: garygrossgarten/github-action-ssh@0.7.0
42-
# with:
43-
# command: |
44-
# sudo systemctl nginx -t
45-
# sudo systemctl restart nginx
46-
# sudo systemctl start redoc.service
47-
# host: ${{ secrets.REMOTE_HOST }}
48-
# username: ${{ secrets.REMOTE_USER }}
49-
# privatekey: ${{ secrets.REMOTE_SSH_KEY }}
44+
platforms: linux/amd64 # 指定平台为 amd64
45+
context: ./ReDocSample
46+
file: ./ReDocSample/Dockerfile
47+
builder: ${{ steps.buildx.outputs.name }}
48+
push: true
49+
tags: |
50+
${{ vars.REGISTRY_URL }}/k8s/redoc:${{ env.run_id }}
51+
${{ vars.REGISTRY_URL }}/k8s/redoc:latest
52+
${{ vars.REGISTRY_URL }}/release/redoc:${{ env.run_id }}
53+
${{ vars.REGISTRY_URL }}/release/redoc:latest
54+
55+
create_release:
56+
runs-on: ubuntu-latest
57+
needs: build
58+
59+
steps:
60+
- name: Create release
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
tag: ${{ github.ref_name }}
64+
run: |
65+
gh release create "${{github.run_id}}.${{ github.run_attempt }}" \
66+
--repo="$GITHUB_REPOSITORY" \
67+
--title="${GITHUB_REPOSITORY#*/} ${{github.run_id}}.${{ github.run_attempt }}" \
68+
--generate-notes
69+
70+
trigger_azure_pipeline:
71+
runs-on: arc-runner-set
72+
needs: create_release
73+
74+
steps:
75+
- name: Trigger Azure DevOps Pipeline
76+
uses: Azure/pipelines@v1.2
77+
with:
78+
azure-devops-project-url: '${{ secrets.AZURE_DEVOPS_PROJECT_URL }}'
79+
azure-pipeline-name: 'ReDoc-CD'
80+
azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}'
81+
azure-pipeline-variables: '{"GITHUB_RUN_ID": "${{ github.run_id }}", "GITHUB_RUN_ATTEMPT": "${{ github.run_attempt }}"}'

0 commit comments

Comments
 (0)