fest : add ci #2
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: wheretobin-cicd | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
env: | |
REGION: asia-southeast1 | |
jobs: | |
# ============== | |
# CI task | |
# ============== | |
build-and-push-image: | |
name: Build Docker image and push to repositories | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
module: | |
[ | |
backend, | |
frontend | |
] | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
- name: Setup SHA | |
run: echo "GITHUB_SHA=${GITHUB_SHA}" >> $GITHUB_ENV | |
- id: "auth" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}" | |
- name: "Set up Cloud SDK" | |
uses: "google-github-actions/setup-gcloud@v1" | |
- name: "Use gcloud CLI" | |
run: "gcloud info" | |
- name: "Docker auth" | |
run: |- | |
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | |
- name: Build image | |
run: docker build -f Dockerfile -t ${{ env.GAR_LOCATION }}/${{ matrix.module }}:${{ env.GITHUB_SHA }} . | |
working-directory: ${{ matrix.module }} | |
- name: Push image | |
run: docker push ${{ env.GAR_LOCATION }} |