Skip to content

Merge pull request #770 from sapuri/rm-useless-methods #694

Merge pull request #770 from sapuri/rm-useless-methods

Merge pull request #770 from sapuri/rm-useless-methods #694

Workflow file for this run

name: app
on: push
jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pipenv
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
- name: Install dependencies
run: pipenv sync --dev
- name: Lint
run: pipenv run lint
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: password
POSTGRES_DB: ci
permissions:
contents: read
id-token: write
env:
ALLOWED_HOSTS: 127.0.0.1
DATABASE_ENGINE: django.db.backends.postgresql
DATABASE_NAME: ci
DATABASE_USER: test
DATABASE_PASSWORD: password
DATABASE_HOST: 127.0.0.1
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pipenv
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
- name: Install dependencies
run: pipenv sync
- name: Migration
run: pipenv run python manage.py migrate
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/682889726379/locations/global/workloadIdentityPools/github-actions/providers/github-actions
service_account: github@srandom.iam.gserviceaccount.com
- name: Test
run: pipenv run test
deploy:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
SERVICE: app
REGION: asia-northeast1
IMAGE_APP: asia-northeast1-docker.pkg.dev/srandom/app/app:${{ github.sha }}
IMAGE_CMD_UPDATE_MUSIC: asia-northeast1-docker.pkg.dev/srandom/cmd/update-music:${{ github.sha }}
IMAGE_CMD_EXPORT2CSV: asia-northeast1-docker.pkg.dev/srandom/cmd/export2csv:${{ github.sha }}
steps:
- uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/682889726379/locations/global/workloadIdentityPools/github-actions/providers/github-actions
service_account: github@srandom.iam.gserviceaccount.com
- name: Configure auth
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
- name: Build and push containers
run: |
./scripts/decrypt-env.sh production
docker build . -f docker/Dockerfile -t ${{ env.IMAGE_APP }}
docker build . -f docker/Dockerfile_update_music -t ${{ env.IMAGE_CMD_UPDATE_MUSIC }}
docker build . -f docker/Dockerfile_export2csv -t ${{ env.IMAGE_CMD_EXPORT2CSV }}
docker push ${{ env.IMAGE_APP }}
docker push ${{ env.IMAGE_CMD_UPDATE_MUSIC }}
docker push ${{ env.IMAGE_CMD_EXPORT2CSV }}
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE }}
image: ${{ env.IMAGE_APP }}
region: ${{ env.REGION }}
- name: Update Cloud Run Jobs
run: |
gcloud beta run jobs update update-music --image ${{ env.IMAGE_CMD_UPDATE_MUSIC }} --region asia-northeast1
gcloud beta run jobs update export2csv --image ${{ env.IMAGE_CMD_EXPORT2CSV }} --region asia-northeast1