Update nginx.conf #19
Workflow file for this run
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 pull request | |
on: | |
pull_request_target: | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
TAG: pr-${{ github.event.pull_request.number }} | |
DOMAIN: echo-pr-${{ github.event.pull_request.number }}.dev.xuexb.com | |
jobs: | |
build-pr: | |
environment: test | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.meta.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Checkout PR | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
path: source | |
- name: Merge PR | |
run: | | |
rm -rf source/.github/workflows | |
cp -r source/* . | |
rm -rf source | |
- 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=raw,value=${{ env.TAG }} | |
- 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-pr: | |
environment: test | |
runs-on: ubuntu-latest | |
needs: build-pr | |
if: ${{ needs.build-pr.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-pr.outputs.version }} | |
dyups-server: ${{ secrets.DYUPS_SERVER }} | |
dyups-token: ${{ secrets.DYUPS_TOKEN }} | |
domain: ${{ env.DOMAIN }} | |
container-port: 8080 | |
comment-pr: | |
environment: test | |
runs-on: ubuntu-latest | |
needs: deploy-pr | |
if: ${{ needs.deploy-pr.result == 'success' }} | |
steps: | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `**Welcome**, The deployment is successful, please visit <https://${{ env.DOMAIN }}> .✨` | |
}) |