fix: 修复 pr 关闭时环境变量 #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
branches: | |
- master | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
DOMAIN: echo.xuexb.com | |
jobs: | |
build-prd: | |
environment: prd | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.meta.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.PERSONAL_ACCESS_NAME }} | |
password: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy-prd: | |
environment: prd | |
runs-on: ubuntu-latest | |
needs: build-prd | |
if: ${{ needs.build-prd.result == 'success' }} | |
steps: | |
- name: deploy | |
uses: xuexb/dyups-actions/deploy@master | |
with: | |
ssh-host: ${{ secrets.SSH_HOST }} | |
ssh-username: ${{ secrets.SSH_USERNAME }} | |
ssh-key: ${{ secrets.SSH_KEY }} | |
ssh-port: ${{ secrets.SSH_PORT }} | |
image: ${{ env.IMAGE_NAME }}:${{ needs.build-prd.outputs.version }} | |
dyups-server: ${{ secrets.DYUPS_SERVER }} | |
dyups-token: ${{ secrets.DYUPS_TOKEN }} | |
domain: ${{ env.DOMAIN }} | |
container-port: 8080 |