💚 deployFix: ポート追加 #27
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 to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
env: | |
SERVICE_NAME: 'yuru-sprint' | |
REGION: 'asia-northeast1' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ secrets.WIF_PROVIDER }} | |
service_account: ${{ secrets.SA_EMAIL }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.PROJECT_ID }} | |
install_components: 'beta' | |
- name: Build Docker image | |
run: | | |
docker build --no-cache --build-arg NODE_ENV=production -t gcr.io/${{ secrets.PROJECT_ID }}/${{ env.SERVICE_NAME }}:$GITHUB_SHA . | |
- name: Push Docker image | |
run: | | |
gcloud auth configure-docker | |
docker push gcr.io/${{ secrets.PROJECT_ID }}/${{ env.SERVICE_NAME }}:$GITHUB_SHA | |
- name: Create .env file | |
run: echo "${{ secrets.ENV_FILE }}" > .env | |
- name: Create env.yaml for Cloud Run | |
run: | | |
source .env | |
cat << EOF > env.yaml | |
SLACK_BOT_TOKEN: '${SLACK_BOT_TOKEN}' | |
NODE_ENV: '${NODE_ENV}' | |
NOTION_INTEGRATION_TOKEN: '${NOTION_INTEGRATION_TOKEN}' | |
NOTION_DATABASE_ID: '${NOTION_DATABASE_ID}' | |
USER_IDS: '${USER_IDS}' | |
USER_NAMES: '${USER_NAMES}' | |
CHANNEL_IDS: '${CHANNEL_IDS}' | |
WEBHOOK_URLS: '${WEBHOOK_URLS}' | |
EOF | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy ${{ env.SERVICE_NAME }} \ | |
--image gcr.io/${{ secrets.PROJECT_ID }}/${{ env.SERVICE_NAME }}:$GITHUB_SHA \ | |
--platform managed \ | |
--region ${{ env.REGION }} \ | |
--allow-unauthenticated \ | |
--env-vars-file env.yaml \ | |
--set-env-vars PORT=8080 |