Skip to content

Commit

Permalink
create a matrix in order to have reusable GHA code across portals
Browse files Browse the repository at this point in the history
  • Loading branch information
lukey-luke committed Feb 5, 2025
1 parent 3bf563a commit 3f9c0d3
Showing 1 changed file with 104 additions and 23 deletions.
127 changes: 104 additions & 23 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ env:
ENV: "github-ci"

jobs:
docker_build_rails_web_portal:
docker_build_rails_apps:
runs-on: self-hosted
strategy:
matrix:
repository: [web-portal, web-admin, web]
include:
# note this is confusing, but make ci-web-portal points to dpc-web-portal-test.sh which runs
# docker compose -p ... dpc_web
- repository: web-portal
make_command: make ci-portal
- repository: web-admin
make_command: make ci-admin-portal
- repository: web
make_command: make ci-web-portal
env:
REPOSITORY: web-portal
MAKE_COMMAND: ${{ matrix.make_command }}
steps:
- name: check gzip
run: gzip --version

- name: Install python3
run: sudo dnf install python3

Expand All @@ -37,42 +46,41 @@ jobs:
sudo chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
# TODO replace w/ make ci-portals-v1 when disk space issue resolved
- name: Build portal
run: |
make ci-portal
- name: Build specified app
run: $MAKE_COMMAND

# run: docker save dpc-$REPOSITORY:latest | gzip > ${{ runner.temp }}/dpc_$REPOSITORY_latest.tar.gz
- name: gzip the image
run: docker save dpc-$REPOSITORY:latest | gzip > ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
run: docker save dpc-${{ matrix.repository }}:latest | gzip > ${{ runner.temp }}/dpc_${{ matrix.repository }}_latest.tar.gz
- name: upload tar artifact
uses: actions/upload-artifact@v4
with:
name: dpc-$REPOSITORY
path: ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
name: dpc-${{ matrix.repository }}
path: ${{ runner.temp }}/dpc_${{ matrix.repository }}_latest.tar.gz

docker_push_rails_web_portal_image:
docker_push_rails_apps:
runs-on: self-hosted
strategy:
matrix:
repository: [web-portal, web-admin, web]
env:
REPOSITORY: web-portal
needs: docker_build_rails_web_portal
REPOSITORY: ${{ matrix.repository }}
needs: docker_build_rails_apps
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dpc-$REPOSITORY
name: dpc-${{ matrix.repository }}
path: ${{ runner.temp }}

- name: Load image
- name: Load docker image from artifact download
run: |
docker load --input ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
docker load --input ${{ runner.temp }}/dpc_${{ matrix.repository }}_latest.tar.gz
docker image ls -a
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-dev-github-actions

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
Expand All @@ -87,8 +95,81 @@ jobs:
docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
- name: success
run: "Did it work???"
# TODO add additional steps to push dpc-web-admin and dpc-web, see docker_build_all_portals below
run: echo "success?"


# docker_build_web_portal:
# runs-on: self-hosted
# env:
# REPOSITORY: web-portal
# MAKE_COMMAND: make ci-portal
# steps:
# - name: check gzip
# run: gzip --version
#
# - name: Install python3
# run: sudo dnf install python3
#
# - name: "Checkout code"
# uses: actions/checkout@v4
#
# - name: Install docker compose manually
# run: |
# sudo mkdir -p /usr/local/lib/docker/cli-plugins
# sudo curl -SL https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
# sudo chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
# sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
#
# - name: Build portal
# run: |
# $MAKE_COMMAND
#
# - name: gzip the image
# run: docker save dpc-$REPOSITORY:latest | gzip > ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
# - name: upload tar artifact
# uses: actions/upload-artifact@v4
# with:
# name: dpc-$REPOSITORY
# path: ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
#
# docker_push_rails_web_portal_image:
# runs-on: self-hosted
# env:
# REPOSITORY: web-portal
# needs: docker_build_rails_web_portal
# steps:
# - name: Download artifact
# uses: actions/download-artifact@v4
# with:
# name: dpc-$REPOSITORY
# path: ${{ runner.temp }}
#
# - name: Load image
# run: |
# docker load --input ${{ runner.temp }}/dpc_web-portal_latest.tar.gz
# docker image ls -a
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: ${{ vars.AWS_REGION }}
# role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-dev-github-actions
#
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
#
# - name: Push to ECR
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker tag dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:latest
# docker tag dpc-$REPOSITORY:latest $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
# docker push $REGISTRY/dpc-$REPOSITORY:$IMAGE_TAG
#
# - name: success
# run: "Did it work???"
# # TODO add additional steps to push dpc-web-admin and dpc-web, see docker_build_all_portals below

# docker_build_all_portals:
# runs-on: self-hosted
Expand Down

0 comments on commit 3f9c0d3

Please sign in to comment.