deploy #19
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: deploy | |
on: | |
workflow_dispatch | |
jobs: | |
deploy: | |
name: deploy | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
contents: write # デプロイの証拠にmain直pushするためだけ | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ToshihitoKon/slack-quickpost@v1 | |
with: | |
version: 0.7.1 | |
- run: | | |
slack-quickpost \ | |
--token ${{ secrets.SLACK_TOKEN}} \ | |
--channel ${{ secrets.SLACK_CHANNEL }} \ | |
--username "GitHub Actions: ${{ github.workflow }}" \ | |
--text ":black_square_for_stop: Waiting manual approve..." | |
- name: Wait manual approve | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash -xe {0} | |
timeout-minutes: 5 | |
run: | | |
ghRunListCmd="gh run list --workflow approve --branch ${{ github.ref_name }} --status success --json headSha --jq ".[].headSha" --limit 1" | |
isApproved=false | |
until ${isApproved}; do | |
sleep 10 | |
result=$(${ghRunListCmd}) | |
# github.shaが一致すればOK | |
if [ "${{ github.sha }}" = "${result}" ]; then | |
isApproved=true | |
fi | |
done | |
- run: | | |
slack-quickpost \ | |
--token ${{ secrets.SLACK_TOKEN}} \ | |
--channel ${{ secrets.SLACK_CHANNEL }} \ | |
--username "GitHub Actions: ${{ github.workflow }}" \ | |
--text ":thumbsup: Deploy Approved!\nhash: ${{ github.sha }}" | |
- name: Deploy | |
# デプロイの例として、README.mdのLast deployを更新する | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "GitHub Actions" | |
sed -i "s/Last deploy.*/Last deploy: ${{ github.sha }}/" README.md | |
git add README.md | |
git commit -m 'Actionsからmainに直push' | |
git push -u origin main | |
- run: | | |
slack-quickpost \ | |
--token ${{ secrets.SLACK_TOKEN}} \ | |
--channel ${{ secrets.SLACK_CHANNEL }} \ | |
--username "GitHub Actions: ${{ github.workflow }}" \ | |
--text ":tada: Deploy complete!" |