Skip to content

Commit

Permalink
ci: separate builds
Browse files Browse the repository at this point in the history
  • Loading branch information
busla committed Feb 21, 2021
1 parent ed6450b commit 6eb7a4e
Showing 1 changed file with 76 additions and 20 deletions.
96 changes: 76 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
name: Setup and build
runs-on: ubuntu-20.04
outputs:
artifact: ${{ steps.zip_build.outputs.artifact }}
branch_name: ${{ steps.extract_branch.outputs.branch_name }}
steps:
#----------------------------------------------
Expand Down Expand Up @@ -65,29 +64,85 @@ jobs:
- name: Install dependencies
run: poetry install
if: steps.cached_poetry_dependencies.outputs.cache-hit != 'true'
build-undirbuningur-stae:
name: Build undirbuningur-stae
runs-on: ubuntu-20.04
outputs:
artifact: ${{ steps.zip_build.outputs.artifact }}
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# Build
#----------------------------------------------
- name: Build undirbuningur-stae
id: build_undirbuningur_stae
run: |
ls -alR projects
source .venv/bin/activate
sphinx-build -c ${{ github.workspace }}/projects/foundation/ ${{ github.workspace }}/projects/foundation/ ${{ github.workspace }}/artifacts/foundation_build
ls -al ${{ github.workspace }}/artifacts
- name: zip-build
id: zip_build
# Use zip instead of tar to support non-tech users that want to download the artifact
run: |
echo ${{ github.workspace }}
ls ${{ github.workspace }}/artifacts
export BUILD_PREFIX=build-${{ runner.os }}
export BUILD_HASH=${{ hashFiles('artifacts') }}
echo ${BUILD_HASH}
zip -r "${BUILD_PREFIX}-${BUILD_HASH}" artifacts/*
ls -al ${{ github.workspace }}
echo "::set-output name=artifact::$(echo ${BUILD_PREFIX}-${BUILD_HASH}.zip)"
#----------------------------------------------
# Upload build artifact
#----------------------------------------------
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: artifacts
path: ${{steps.zip_build.outputs.artifact}}
build-greining-1:
name: Build Greining-1
runs-on: ubuntu-20.04
outputs:
artifact: ${{ steps.zip_build.outputs.artifact }}
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# Build
#----------------------------------------------
- name: Build greining-1
id: build_greining_1
run: |
ls -alR projects
source .venv/bin/activate
sphinx-build -c ${{ github.workspace }}/projects/analysis_1/ ${{ github.workspace }}/projects/analysis_1/ ${{ github.workspace }}/artifacts/analysis_1_build
curl https://notendur.hi.is/jlg2/staging/greining-1/${{ steps.extract_branch.outputs.branch_name }}/.buildinfo -o .prodbuild
if cmp --silent -- .prodbuild projects/analysis_1/.buildinfo; then
echo "no changes, skipping deploy"
exit 78
else
echo "changes found, lets deploy"
fi
ls -al ${{ github.workspace }}/artifacts
- name: zip-build
id: zip_build
Expand All @@ -109,7 +164,6 @@ jobs:
with:
name: artifacts
path: ${{steps.zip_build.outputs.artifact}}

tag-and-release:
needs: setup
name: Tag and release
Expand Down Expand Up @@ -168,8 +222,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_prerelease.outputs.upload_url }}
asset_path: ${{needs.setup.outputs.artifact}}
asset_name: ${{needs.setup.outputs.artifact}}
asset_path: artifact
asset_name: artifact
asset_content_type: application/zip
- name: Upload release asset
if: needs.setup.outputs.branch_name == 'master'
Expand All @@ -179,11 +233,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{needs.setup.outputs.artifact}}
asset_name: ${{needs.setup.outputs.artifact}}
asset_path: artifact
asset_name: artifact
asset_content_type: application/zip
deploy-feature-branch:
needs: [setup, tag-and-release]
needs: [setup, build-greining-1, build-undirbuningur-stae, tag-and-release]
if: needs.setup.outputs.branch_name != 'master'
name: Deploy feature branch
runs-on: ubuntu-20.04
Expand All @@ -201,8 +255,9 @@ jobs:
- name: Unzip build
# greining-1/monorepo-demo/artifacts/analysis_1_build/
run: |
unzip ${{needs.setup.outputs.artifact}} && mv ${{ github.workspace }}/artifacts/* ${{ github.workspace }}/
rm ${{needs.setup.outputs.artifact}}
unzip artifact && mv ${{ github.workspace }}/artifacts/* ${{ github.workspace }}/
ls -al .
rm *.zip
ls -al .
#----------------------------------------------
# Delete dir on remote server, upload build tar and extract on remote server.
Expand Down Expand Up @@ -250,8 +305,9 @@ jobs:
- name: Unzip build
# greining-1/monorepo-demo/artifacts/analysis_1_build/
run: |
unzip ${{needs.setup.outputs.artifact}}
rm ${{needs.setup.outputs.artifact}}
ls -al .
unzip *.zip
rm *.zip
ls -al .
- name: Deploy foundation to prod
id: deploy_foundation_prod
Expand Down

0 comments on commit 6eb7a4e

Please sign in to comment.