diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index abcf805..ab36dde 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,29 +1,26 @@ -name: Deploy Discord-Study +name: Create and publish a Docker image to GCP Artifact Registry on: push: branches: - - "main" + - main + +env: + REGISTRY: ${{ secrets.GAR_REGISTRY }} + IMAGE_NAME: image jobs: - deploy: + build-and-push-image: runs-on: ubuntu-latest + permissions: + contents: read steps: - - name: code checkout - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 - - name: install gcloud CLI - uses: google-github-actions/setup-gcloud@v1 + - name: Log in to the Container registry + uses: docker/login-action@v2 with: - project_id: ${{secrets.GOOGLE_PROJECT}} - service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}} - export_default_credentials: true - - # Configure docker to use the g cloud command-line tool as a credential helper - - name: gcloud auth configure-docker - env: - GOOGLE_PROJECT: ${{secrets.GOOGLE_PROJECT}} - run: | - gcloud auth configure-docker us-central1-docker.pkg.dev - docker build -t us-central1-docker.pkg.dev/discord-study-bot-420101/discord-study-docker/image:latest . - ## docker push us-central1-docker.pkg.dev/discord-study-bot-420101/discord-study-docker/discord-study-docker:latest + registry: ${{ env.REGISTRY }} + username: _json_key + password: ${{ secrets.GAR_JSON_KEY }}