Skip to content

Commit

Permalink
Merge branch 'main' into demo
Browse files Browse the repository at this point in the history
  • Loading branch information
brown-a2 committed Jun 14, 2024
2 parents 52beef4 + de7f23e commit 4f1c89b
Showing 1 changed file with 94 additions and 63 deletions.
157 changes: 94 additions & 63 deletions .github/workflows/rw-build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,81 +72,112 @@ on:

jobs:
buildImage:
name: Build Image and push to ECR
runs-on: ubuntu-latest
environment: ${{inputs.environment}}
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: Checkout
uses: actions/checkout@v4
name: Build Image and push to ECR
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Config Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ecr-role }}
aws-region: ${{ secrets.ecr-region }}
- name: Config Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ecr-role }}
aws-region: ${{ secrets.ecr-region }}

- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
with:
mask-password: 'true'
- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
with:
mask-password: 'true'

- name: Build and Push Nginx Image
run: |
docker build --pull --no-cache --tag $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG --file nginx.dockerfile .
docker push $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run Composer
run: |
composer config http-basic.repo.packagist.com ${{ secrets.cp-user }} ${{ secrets.cp-password }}
composer config http-basic.connect.advancedcustomfields.com ${{ secrets.acf-user }} ${{ secrets.acf-password }}
composer install --prefer-dist --no-progress
- name: Cache Docker layers for Nginx
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache-nginx
key: ${{ runner.os }}-buildx-nginx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-nginx-
- name: Cache NPM Dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
wordpress/wp-content/themes/hale/node_modules
wordpress/wp-content/themes/hale-dash/node_modules
wordpress/wp-content/themes/brookhouse/node_modules
wordpress/wp-content/themes/lawcom/node_modules
wordpress/wp-content/themes/justicejobs/node_modules
wordpress/wp-content/themes/ppo/node_modules
wordpress/wp-content/themes/sifocc/node_modules
wordpress/wp-content/themes/imbmembers/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build and Push Nginx Image
run: |
docker buildx create --use
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache-nginx \
--cache-to=type=local,dest=/tmp/.buildx-cache-nginx \
--pull \
--push \
--tag $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG \
--file nginx.dockerfile .
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}

- name: Run NPM
run: |
for theme in hale hale-dash brookhouse lawcom justicejobs ppo sifocc imbmembers; do
npm install --prefix ./wordpress/wp-content/themes/$theme
npm run production --if-present --prefix ./wordpress/wp-content/themes/$theme
done
- name: Run Composer
run: |
composer config http-basic.repo.packagist.com ${{ secrets.cp-user }} ${{ secrets.cp-password }}
composer config http-basic.connect.advancedcustomfields.com ${{ secrets.acf-user }} ${{ secrets.acf-password }}
composer install --prefer-dist --no-progress
- name: Build and Push Wordpress Image
run: |
docker build --pull --no-cache --tag $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG --file wordpress.dockerfile .
docker push $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}
- name: Cache NPM Dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
wordpress/wp-content/themes/hale/node_modules
wordpress/wp-content/themes/hale-dash/node_modules
wordpress/wp-content/themes/brookhouse/node_modules
wordpress/wp-content/themes/lawcom/node_modules
wordpress/wp-content/themes/justicejobs/node_modules
wordpress/wp-content/themes/ppo/node_modules
wordpress/wp-content/themes/sifocc/node_modules
wordpress/wp-content/themes/imbmembers/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Run NPM
run: |
for theme in hale hale-dash brookhouse lawcom justicejobs ppo sifocc imbmembers; do
npm install --prefix ./wordpress/wp-content/themes/$theme
npm run production --if-present --prefix ./wordpress/wp-content/themes/$theme
done
- name: Cache Docker layers for WordPress
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache-wordpress
key: ${{ runner.os }}-buildx-wordpress-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-wordpress-
- name: Build and Push WordPress Image
run: |
docker buildx create --use
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache-wordpress \
--cache-to=type=local,dest=/tmp/.buildx-cache-wordpress \
--pull \
--push \
--tag $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG \
--file wordpress.dockerfile .
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}

deployImage:
name: Deploy to Environment
needs: [buildImage]
runs-on: ubuntu-latest
environment: ${{inputs.environment}}
environment: ${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down

0 comments on commit 4f1c89b

Please sign in to comment.