Update deploy-test-environment.yml (#13136)

This commit is contained in:
Srgr0 2024-02-02 11:58:43 +09:00 committed by GitHub
parent 85809a240e
commit 3499814498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,66 +1,23 @@
name: Deploy test environment name: deploy-test-environment
on: on:
push: #push:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
repository: repository:
description: 'Repository to deploy (optional)' description: 'Repository to deploy (optional)'
type: string
required: false required: false
branch: branch_or_hash:
description: 'Branch to deploy (optional)' description: 'Branch or Commit hash to deploy (optional)'
type: string
required: false required: false
jobs: jobs:
deploy-test-environment: deploy-test-environment:
runs-on: ubuntu-latest uses: joinmisskey/misskey-tga/.github/workflows/deploy-test-environment.yml@main
steps: with:
- name: Set environment variable (for tput command & pnpm) repository: ${{ github.event.inputs.repository }}
run: | branch_or_hash: ${{ github.event.inputs.branch_or_hash }}
echo "TERM=xterm" >> $GITHUB_ENV secrets:
REPOSITORY=${{ github.event.inputs.repository || github.repository }} DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
BRANCH=${{ github.event.inputs.branch || github.ref_name }}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: ${{ env.BRANCH }}
- name: Get the latest commit SHA
run: |
SHA=$(git log -1 --format="%H")
echo "SHA=$SHA" >> $GITHUB_ENV
- name: Start cloudflare tunnel (quick)
run: |
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
sudo cloudflared tunnel --metrics localhost:55555 --url localhost:3000 > /dev/null 2>&1 &
sleep 15
TUNNEL_RESPONSE=$(curl http://localhost:55555/quicktunnel)
TUNNEL_DOMAIN=$(echo $TUNNEL_RESPONSE | grep -o '"hostname":"[^"]*' | grep -o '[^"]*$')
echo "::add-mask::$TUNNEL_DOMAIN"
echo "TUNNEL_DOMAIN=$TUNNEL_DOMAIN" >> $GITHUB_ENV
- name: Install misskey
run: |
wget https://raw.githubusercontent.com/joinmisskey/bash-install/v4/misskey-install.sh
wget https://raw.githubusercontent.com/joinmisskey/bash-install/v4/testenv_githubactions.txt
sed -i "s/host=127.0.0.1/host=$TUNNEL_DOMAIN/g" testenv_githubactions.txt
sed -i "s|git_repository=https://github.com/misskey-dev/misskey|git_repository=https://github.com/$REPOSITORY|g" testenv_githubactions.txt
sed -i "s|git_branch=master|git_branch=$BRANCH|g" testenv_githubactions.txt
sudo chmod 555 ./misskey-install.sh
sudo bash -x ./misskey-install.sh -c ./testenv_githubactions.txt
- name: Post tunnel info to Discord
run: |
CURRENT_TIME=$(TZ=Asia/Tokyo date +'%Y-%m-%d %H:%M:%S JST')
COMMIT_URL="https://github.com/$REPOSITORY/commit/$SHA"
curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"==============================\nURL: https://$TUNNEL_DOMAIN\nRepository: $REPOSITORY\nBranch: $BRANCH\nCommit: $COMMIT_URL\nTime: $CURRENT_TIME\n==============================\"}" ${{ secrets.DISCORD_WEBHOOK_URL }}
- name: Wait
run: |
timeout 3600 tail -f /var/log/syslog || true