Skip to content

deploy

deploy #9

Workflow file for this run

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
timeout-minutes: 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
isApproved=false
until ${isApproved}; do
sleep 10
result=$(gh run list \
--workflow approve \
--status success \
--branch ${{ github.ref_name }} \
--json headSha \
--jq '.[].headSha' \
--limit 1)
# 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 }}"
- 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!"