Skip to content

Commit

Permalink
Merge pull request #119 from USEPA/update-build-workflows
Browse files Browse the repository at this point in the history
Update build workflows
  • Loading branch information
elinork authored Oct 25, 2023
2 parents 0f8c89b + dcb01f7 commit ff9e61c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 30 deletions.
70 changes: 40 additions & 30 deletions .github/workflows/build-cloud-gov.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
name: Copy R Shiny app to cloud-gov branch and request push to dev

on:
push:
branches:
- develop
workflow_dispatch:
inputs:
build_deps:
description: 'Also build R dependencies?'
required: true
default: true
type: boolean
build_bins:
description: 'Also build binaries?'
required: true
default: false
type: boolean

permissions:
contents: write
Expand All @@ -16,7 +24,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: cloud-gov
Expand All @@ -27,7 +35,7 @@ jobs:
if [ -d "main-branch" ]; then rm -fr main-branch; fi
- name: Checkout default branch to main-branch path
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
path: main-branch
Expand All @@ -46,6 +54,7 @@ jobs:
BUILD_DEPS: ${{ inputs.build_deps }}

download_and_vendor_dependencies:
if: ${{ inputs.build_deps }}
needs: copy_code_to_cloud-gov
runs-on: ubuntu-latest
name: Compile and vendor R dependencies for cloud.gov
Expand All @@ -59,7 +68,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: cloud-gov
Expand Down Expand Up @@ -108,28 +117,28 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

# - name: Run lib_tar.sh to extract each of the libraries needed by sf
# if: ${{ env.needs_geo == 'true' }}
# run: |
# if [ -d "r-lib" ]; then rm -fr r-lib; fi
# mkdir r-lib
# chmod +x scripts/lib_tar.sh
# for L in $LIBS
# do
# find / -iname $L 2>/dev/null | xargs -I {} scripts/lib_tar.sh {}
# done
# scripts/lib_tar.sh /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 # Another libsqlite3.so.0 exists on the image
# git add r-lib
# env:
# LIBS: libudunits2.so.0 libgeos_c.so libproj.so.22 proj.db libgdal.so.30

# - name: Copy pandoc executable
# if: ${{ env.needs_pandoc == 'true' }}
# run: |
# if [ -d "r-bin" ]; then rm -fr r-bin; fi
# mkdir r-bin
# cp /usr/bin/pandoc r-bin
# git add r-bin
- name: Run lib_tar.sh to extract each of the libraries needed by sf
if: ${{ env.needs_geo == 'true' && inputs.build_bins }}
run: |
if [ -d "lib" ]; then rm -fr lib; fi
mkdir lib
chmod +x scripts/lib_tar.sh
for L in $LIBS
do
find / -iname $L 2>/dev/null | xargs -I {} scripts/lib_tar.sh {}
done
scripts/lib_tar.sh /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 # Another libsqlite3.so.0 exists on the image
git add lib
env:
LIBS: libudunits2.so.0 libgeos_c.so libproj.so.22 proj.db libgdal.so.30
- name: Copy pandoc executable
if: ${{ env.needs_pandoc == 'true' && inputs.build_bins }}
run: |
if [ -d "bin" ]; then rm -fr bin; fi
mkdir bin
cp /usr/bin/pandoc bin
git add bin
- name: Add additional files to repo if not already there
run: |
Expand All @@ -152,7 +161,6 @@ jobs:
name: debug-outputs
path: debug-outputs


- name: Commit & Push
if: ${{ success() }}
run: |
Expand All @@ -163,7 +171,9 @@ jobs:
request_copy:
# Note: this step will fail if OWSHINY_ACTION secret is not set up in the repo and should be removed
name: Request copy uploaded to deployment repo if permitted
needs: download_and_vendor_dependencies
needs: [copy_code_to_cloud-gov, download_and_vendor_dependencies]
if: always() && !contains(needs.*.result, 'failure')
# Needs to run even if download_and_vendor_dependencies was skipped
runs-on: ubuntu-latest
steps:
- name: Trigger Workflow to copy for deployment
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/trigger-build-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Triggers build-cloud-gov workflow

on:
push:
branches:
- develop

jobs:
trigger-build:
runs-on: ubuntu-latest
name: Triggers build on push with desired defaults

steps:
- name: Trigger cloud.gov build with desired inputs
uses: actions/github-script@v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: 'USEPA',
repo: 'TADAShiny',
workflow_id: 'build-cloud-gov.yml',
ref: 'develop',
inputs: {
"build_deps": true,
"build_bins": false,
}
})

0 comments on commit ff9e61c

Please sign in to comment.