close #381: Update Nigeria cities AQ map & statistics view (#382) #94
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: main | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: "${{ github.workflow }} @ ${{ github.ref }}" | |
| cancel-in-progress: true | |
| env: | |
| DOKKU_REMOTE_BRANCH: "master" | |
| DOKKU_REMOTE_URL: "ssh://dokku@ui-2.prod.codeforafrica.org/sensors-africa-ui" | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GIT_PUSH_FLAGS: "--force" | |
| IMAGE_NAME: "codeforafrica/sensors-africa-ui" | |
| NEXT_PUBLIC_APP_API_BASE_URL: "https://api.sensors.africa/v2" | |
| NEXT_PUBLIC_APP_API_DOCS_URL: "https://api.sensors.africa/docs" | |
| NEXT_PUBLIC_APP_API_STATIC_URL: "https://api.sensors.africa/static/v2" | |
| NEXT_PUBLIC_APP_MAP_URL: "https://v2.map.aq.sensors.africa" | |
| jobs: | |
| deploy: | |
| strategy: | |
| matrix: | |
| node-version: [20.16] | |
| os: [ubuntu-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| # Set up Node since it's required by version-check | |
| # https://github.com/EndBug/version-check#github-workflow | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Check if version is bumped | |
| id: version-check | |
| uses: EndBug/version-check@v2 | |
| with: | |
| # Whether to search in every commit's diff. | |
| # This is useful if you often do change the version without saying it | |
| # in the commit message. If you always include the semver of the new | |
| # version in your commit message when you bump versions then you can | |
| # omit this. | |
| diff-search: true | |
| - name: Login to Docker Hub | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| - name: Set up QEMU | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: linux/arm64 | |
| - name: Set up Docker Buildx | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache Docker layers | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ runner.temp }}/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Build and push | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| build-args: | | |
| GOOGLE_ANALYTICS_ID=${{ secrets.SENSORS_AFRICA_GA_ANALYTICS_ID }} | |
| NEXT_PUBLIC_APP_API_BASE_URL=${{ env.NEXT_PUBLIC_APP_API_BASE_URL }} | |
| NEXT_PUBLIC_APP_API_DOCS_URL=${{ env.NEXT_PUBLIC_APP_API_DOCS_URL }} | |
| NEXT_PUBLIC_APP_API_STATIC_URL=${{ env.NEXT_PUBLIC_APP_API_STATIC_URL }} | |
| NEXT_PUBLIC_APP_MAP_URL=${{ env.NEXT_PUBLIC_APP_MAP_URL }} | |
| cache-from: type=local,src=${{ runner.temp }}/.buildx-cache | |
| cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max | |
| context: . | |
| platforms: linux/arm64 | |
| push: true | |
| secrets: | | |
| "api_token=${{ secrets.SENSORS_AFRICA_API_TOKEN }}" | |
| tags: "${{ env.IMAGE_NAME }}:${{ steps.version-check.outputs.version }}" | |
| - # Temp fix | |
| # https://github.com/docker/build-push-action/issues/252 | |
| # https://github.com/moby/buildkit/issues/1896 | |
| name: Move cache | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: | | |
| rm -rf ${{ runner.temp }}/.buildx-cache | |
| mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache | |
| - name: Push to Dokku | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: dokku/github-action@v1.0.2 | |
| with: | |
| branch: ${{ env.DOKKU_REMOTE_BRANCH }} | |
| ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| git_push_flags: ${{ env.GIT_PUSH_FLAGS }} | |
| git_remote_url: ${{ env.DOKKU_REMOTE_URL }} |