Skip to content

Commit

Permalink
Disable reusable apps action
Browse files Browse the repository at this point in the history
  • Loading branch information
kilemensi committed Oct 7, 2024
1 parent ed323c2 commit fb0064e
Showing 1 changed file with 92 additions and 92 deletions.
184 changes: 92 additions & 92 deletions .github/workflows/codeforafrica-deploy-review-app.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
name: Code for Africa | Deploy | REVIEW APP
# name: Code for Africa | Deploy | REVIEW APP

on:
pull_request:
paths:
- "apps/codeforafrica/**"
- "Dockerfile"
- ".github/workflows/codeforafrica-deploy-review-app.yml"
# By default, a workflow only runs when a pull_request event's activity
# type is opened, synchronize, or reopened. We need at least closed to
# be able to destroy preview app
types: [opened, reopened, closed, synchronize]
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: false
# on:
# pull_request:
# paths:
# - "apps/codeforafrica/**"
# - "Dockerfile"
# - ".github/workflows/codeforafrica-deploy-review-app.yml"
# # By default, a workflow only runs when a pull_request event's activity
# # type is opened, synchronize, or reopened. We need at least closed to
# # be able to destroy preview app
# types: [opened, reopened, closed, synchronize]
# concurrency:
# group: "${{ github.workflow }} @ ${{ github.ref }}"
# cancel-in-progress: false

env:
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]"
IMAGE_NAME: "codeforafrica/codeforafrica-ui"
ORIGINAL_APP_NAME: "codeforafrica-ui"
NEXT_PUBLIC_APP_URL: "https://codeforafrica-ui-pr-${{github.event.pull_request.number}}.dev.codeforafrica.org"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_NAME: codeforafrica-ui-pr-${{ github.event.pull_request.number }}
# env:
# DOKKU_REMOTE_BRANCH: "master"
# DOKKU_REMOTE_URL: "ssh://[email protected]"
# IMAGE_NAME: "codeforafrica/codeforafrica-ui"
# ORIGINAL_APP_NAME: "codeforafrica-ui"
# NEXT_PUBLIC_APP_URL: "https://codeforafrica-ui-pr-${{github.event.pull_request.number}}.dev.codeforafrica.org"
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# APP_NAME: codeforafrica-ui-pr-${{ github.event.pull_request.number }}

jobs:
deploy_review_app:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [20.16]
os: [ubuntu-latest]
if: github.event_name == 'pull_request' && github.event.action != 'closed'
steps:
- name: Cloning repo
uses: actions/checkout@v4
with:
fetch-depth: 0
# jobs:
# deploy_review_app:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# node-version: [20.16]
# os: [ubuntu-latest]
# if: github.event_name == 'pull_request' && github.event.action != 'closed'
# steps:
# - name: Cloning repo
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: /tmp/.buildx-cache
restore-keys: |
${{ runner.os }}-buildx-
# - name: Cache Docker layers
# uses: actions/cache@v4
# with:
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# path: /tmp/.buildx-cache
# restore-keys: |
# ${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v3
with:
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
username: ${{ secrets.DOCKER_HUB_USERNAME }}
# - name: Login to DockerHub
# uses: docker/login-action@v3
# with:
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# username: ${{ secrets.DOCKER_HUB_USERNAME }}

- name: Build Docker image
uses: docker/build-push-action@v5
with:
build-args: |
MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }}
NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }}
NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }}
NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }}
PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
target: codeforafrica-runner
push: true
tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}"
# - name: Build Docker image
# uses: docker/build-push-action@v5
# with:
# build-args: |
# MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }}
# NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }}
# NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }}
# NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }}
# PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }}
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new
# context: .
# target: codeforafrica-runner
# push: true
# tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}"

- name: Push to dokku
uses: dokku/github-action@master
with:
command: review-apps:create
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/codeforafrica-ui
review_app_name: ${{ env.APP_NAME }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ github.sha }}
# - name: Push to dokku
# uses: dokku/github-action@master
# with:
# command: review-apps:create
# git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/codeforafrica-ui
# review_app_name: ${{ env.APP_NAME }}
# ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
# deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ github.sha }}

- name: Update Preview URL
run: (gh pr comment ${{ env.issue-number }} --edit-last --body='${{ env.body }}' || gh pr comment ${{ env.issue-number }} --body='${{ env.body }}')
env:
issue-number: ${{ github.event.pull_request.number }}
body: |
Latest updated Preview URL
| Name | Review |
|-------|--------|
| ${{ env.APP_NAME }} | [Visit](https://${{ env.APP_NAME }}.dev.codeforafrica.org) |
# - name: Update Preview URL
# run: (gh pr comment ${{ env.issue-number }} --edit-last --body='${{ env.body }}' || gh pr comment ${{ env.issue-number }} --body='${{ env.body }}')
# env:
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# Latest updated Preview URL
# | Name | Review |
# |-------|--------|
# | ${{ env.APP_NAME }} | [Visit](https://${{ env.APP_NAME }}.dev.codeforafrica.org) |

destroy_review_app:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
steps:
- name: Destroy review app
uses: dokku/github-action@master
with:
command: review-apps:destroy
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/codeforafrica-ui
review_app_name: ${{ env.APP_NAME }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
# destroy_review_app:
# runs-on: ubuntu-latest
# if: github.event_name == 'pull_request' && github.event.action == 'closed'
# steps:
# - name: Destroy review app
# uses: dokku/github-action@master
# with:
# command: review-apps:destroy
# git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/codeforafrica-ui
# review_app_name: ${{ env.APP_NAME }}
# ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

0 comments on commit fb0064e

Please sign in to comment.