From 5717dc2868808c3448c730bb958b03d0ca11c34d Mon Sep 17 00:00:00 2001 From: bgharbi Date: Tue, 6 Feb 2024 16:26:08 +0100 Subject: [PATCH] Migrate CI/CD workflow from DigitalOcean to Google Actions This to Google Actions. The workflow steps for DigitalOcean were removed and replaced with steps for Google Artifact Registry. Additionally, new versions of checkout, metadata-action, and build-push-action are now in use. --- .github/workflows/ci.yml | 50 ---------------------------------- .github/workflows/cicd.yml | 55 ++++++++++++-------------------------- 2 files changed, 17 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 2df7c3a..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: gol2 - -on: - push: - branches: - - 'main' - workflow_dispatch: - -jobs: - Build: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.meta.outputs.version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: europe-west9-docker.pkg.dev/gol2-development/gol2-indexer/dev - flavor: latest=false - tags: | - type=ref,suffix=-{{sha}},event=branch - type=ref,suffix=-{{sha}},event=pr - - - uses: 'google-github-actions/auth@v2' - id: auth - with: - token_format: access_token - project_id: 'gol2-development' - credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' - - - name: Login to GAR - uses: docker/login-action@v3 - with: - registry: europe-west9-docker.pkg.dev - username: oauth2accesstoken - password: ${{ steps.auth.outputs.access_token }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - file: Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - secrets: | - "certificate=${{ secrets.CERTIFICATE }}" \ No newline at end of file diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 9a513ef..2df7c3a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -13,59 +13,38 @@ jobs: tag: ${{ steps.meta.outputs.version }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker meta id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: - images: registry.digitalocean.com/governance/gol2-indexer + images: europe-west9-docker.pkg.dev/gol2-development/gol2-indexer/dev flavor: latest=false tags: | type=ref,suffix=-{{sha}},event=branch type=ref,suffix=-{{sha}},event=pr - - name: Login to DO Container Registry - uses: docker/login-action@v2 + - uses: 'google-github-actions/auth@v2' + id: auth with: - registry: registry.digitalocean.com - username: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + token_format: access_token + project_id: 'gol2-development' + credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' + + - name: Login to GAR + uses: docker/login-action@v3 + with: + registry: europe-west9-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.auth.outputs.access_token }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} secrets: | - "certificate=${{ secrets.CERTIFICATE }}" - - Deploy-review: - if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' - needs: Build - runs-on: ubuntu-latest - env: - tag: ${{ needs.Build.outputs.tag }} - steps: - - name: DigitalOcean App Platform deployment - uses: digitalocean/app_action@v1.1.5 - with: - app_name: gol2-review - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - images: '[{"name": "gol2-indexer","image":{"registry_type": "DOCR","repository": "gol2-indexer","tag": "${{ env.tag }}"}}]' - - Deploy-production: - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - needs: Build - runs-on: ubuntu-latest - env: - tag: ${{ needs.Build.outputs.tag }} - steps: - - name: DigitalOcean App Platform deployment - uses: digitalocean/app_action@v1.1.5 - with: - app_name: gol2 - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - images: '[{"name": "gol2-indexer","image":{"registry_type": "DOCR","repository": "gol2-indexer","tag": "${{ env.tag }}"}}]' + "certificate=${{ secrets.CERTIFICATE }}" \ No newline at end of file