fix(ci): update actions/cache to v3 due to deprecation #82
This file contains hidden or 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: Production | |
| on: | |
| push: | |
| branches: | |
| - "[0-9]+.0" | |
| paths: | |
| - "**/workflows/**" | |
| - "**/src/**" | |
| - "**/i18n/**" | |
| - "**.py" | |
| - "**.xml" | |
| - "Dockerfile" | |
| workflow_dispatch: | |
| env: | |
| REQUIRED_MODULES: session_redis,logging_json,attachment_s3,cloud_platform_exoscale # list of addional addons to install separated by comma | |
| GAR_BASE: us-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/odoo-gob | |
| HUB_BASE: gobdo/odoo-gob | |
| IMAGE_LOCATION: iterativodo/dockerdoo | |
| ENV: "prod" | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| get_modules: ${{ steps.get_modules.outputs.modules }} | |
| image_digest: ${{ steps.docker_build.outputs.digest }} | |
| steps: | |
| ### Dependencies | |
| - uses: rlespinasse/[email protected] | |
| - name: Checkout local | |
| uses: actions/checkout@v2 | |
| with: | |
| path: ${{ env.GITHUB_REPOSITORY_SLUG_URL }} | |
| - name: Odoo Enterprise | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: ${{ vars.REPOSITORY_NAME }} | |
| token: ${{ secrets.ACTIONS_PAT }} | |
| path: ${{ vars.REPOSITORY_NAME }} | |
| ref: ${{ env.GITHUB_REF_SLUG }} | |
| # - name: Odoo Themes | |
| # uses: actions/checkout@v2 | |
| # with: | |
| # repository: opticrd/odoo-website-themes | |
| # token: ${{ secrets.ACTIONS_PAT }} | |
| # path: odoo/themes | |
| # ref: ${{ env.GITHUB_REF_SLUG }} | |
| - name: Select Odoo modules to install | |
| id: get_modules | |
| run: | | |
| curl https://raw.githubusercontent.com/iterativo-git/dockerdoo/${{ env.GITHUB_REF_SLUG }}/resources/getaddons.py -o getaddons.py | |
| output=$(python -c "from getaddons import get_modules; print(','.join(get_modules('./${{ env.GITHUB_REPOSITORY_SLUG_URL }}', depth=3)))") | |
| echo "::set-output name=modules::$output" | |
| ### Build the Docker image and Push it | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| with: | |
| driver-opts: network=host | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }} | |
| - name: Login to GAR | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: us-docker.pkg.dev | |
| username: _json_key | |
| password: ${{ secrets.GKE_SA_KEY }} | |
| - name: Login to HUB | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build & push | |
| id: docker_build | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| file: ./${{ env.GITHUB_REPOSITORY_SLUG_URL }}/Dockerfile | |
| tags: | | |
| ${{ env.GAR_BASE }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}:${{ env.GITHUB_REF_SLUG }} | |
| ${{ env.HUB_BASE }}:${{ env.GITHUB_REF_SLUG }} | |
| build-args: | | |
| RUNNING_ENV=${{ env.ENV }} | |
| EXTRA_MODULES=${{ steps.get_modules.outputs.modules }},${{ env.REQUIRED_MODULES }} | |
| IMAGE_LOCATION=${{ env.IMAGE_LOCATION }} | |
| ODOO_VERSION=${{ env.GITHUB_REF_SLUG }} | |
| PGHOST=${{ secrets.DB_PORT_5432_TCP_ADDR_15 }} | |
| PGUSER=${{ secrets.DB_ENV_POSTGRES_USER }} | |
| PGPORT=${{ secrets.DB_PORT_5432_TCP_PORT }} | |
| PGPASSWORD=${{ secrets.DB_ENV_POSTGRES_PASSWORD }} | |
| ODOO_SESSION_REDIS=${{ secrets.ODOO_SESSION_REDIS }} | |
| ODOO_SESSION_REDIS_HOST=${{ secrets.ODOO_SESSION_REDIS_HOST }} | |
| ODOO_SESSION_REDIS_PREFIX=${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}-odoo-${{ env.ENV }} | |
| ODOO_LOGGING_JSON=${{ secrets.ODOO_LOGGING_JSON }} | |
| AWS_HOST=${{ secrets.AWS_HOST }} | |
| AWS_REGION=${{ secrets.AWS_REGION }} | |
| AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_BUCKETNAME=${{ secrets.AWS_BUCKETNAME }} | |
| AWS_BUCKETNAME_UNSTRUCTURED=true | |
| SERVER_WIDE_MODULES=base,web,${{ env.REQUIRED_MODULES }} | |
| push: true | |
| cache-from: type=registry,ref=${{ env.GAR_BASE }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}:${{ env.GITHUB_REF_SLUG }} | |
| cache-to: type=inline | |
| ### Set up Kustomize and build it | |
| - name: K8s Template | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}/odoo-kubernetes-infra | |
| path: gke-dev-cluster | |
| token: ${{ secrets.ACTIONS_PAT }} | |
| ref: main | |
| - uses: imranismail/setup-kustomize@v1 | |
| with: | |
| kustomize-version: "4.5.4" | |
| - run: kustomize build gke-dev-cluster/deployments/odoo/${{ env.ENV }} -o deployment.yaml | |
| - name: Render Deployment YAML | |
| uses: dominicwatson/github-action-envsubst@v1 | |
| with: | |
| files: ./deployment.yaml | |
| patterns: $ENV $GKE_LOCATION $EXTRA_MODULES $PROJECT_ID $REPO_NAME $BRANCH_NAME $ODOO_VERSION $DEPLOY_IMAGE $REPO_URL $BRANCH_URL $SHORT_SHA $STAGING_DB $ODOO_VERSION_URL_SLUG $DEPLOY_DOMAIN | |
| env: | |
| ENV: ${{ env.ENV }} | |
| GKE_LOCATION: ${{ secrets.GKE_ZONE }} | |
| # Modules to Install | |
| EXTRA_MODULES: ${{ steps.get_modules.outputs.modules }},${{ env.REQUIRED_MODULES }} | |
| # Image to Deploy | |
| PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
| REPO_NAME: ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }} | |
| BRANCH_NAME: ${{ env.GITHUB_REF_SLUG}} | |
| ODOO_VERSION: ${{ env.GITHUB_REF_SLUG}} | |
| DEPLOY_IMAGE: ${{ env.GAR_BASE }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}@${{ steps.docker_build.outputs.digest }} | |
| # URL to acccess | |
| REPO_URL: ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }} | |
| BRANCH_URL: ${{ env.GITHUB_REF_SLUG_URL }} | |
| SHORT_SHA: ${{ env.GITHUB_SHA_SHORT }} | |
| ODOO_VERSION_URL_SLUG: ${{ env.GITHUB_REF_SLUG_URL }} | |
| DEPLOY_DOMAIN: ${{ secrets.DEPLOY_DOMAIN }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: deployment-${{ env.GITHUB_REF_SLUG }} | |
| path: deployment.yaml | |
| deploy: | |
| name: GKE Deploy | |
| needs: ["build"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: rlespinasse/[email protected] | |
| - name: Download modules results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: deployment-${{ env.GITHUB_REF_SLUG }} | |
| - run: cat deployment.yaml | |
| - uses: google-github-actions/[email protected] | |
| with: | |
| cluster_name: ${{ secrets.GKE_CLUSTER }} | |
| location: ${{ secrets.GKE_ZONE }} | |
| credentials: ${{ secrets.GKE_SA_KEY }} | |
| project_id: ${{ secrets.GKE_PROJECT }} | |
| - name: Deploy | |
| uses: docker://gcr.io/cloud-builders/gke-deploy | |
| with: | |
| args: run --filename=deployment.yaml --app=${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }} --version=${{ env.GITHUB_REF_SLUG }} --timeout 1800s |