Skip to content

Commit

Permalink
fix(Deploy): Make deployment work again
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Reinhardt committed Jun 3, 2022
1 parent a4c413e commit db394bc
Showing 1 changed file with 56 additions and 17 deletions.
73 changes: 56 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ jobs:
build:
needs: [prepare]
name: Building ${{ matrix.image }} image(s)
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
image: ['ansible','java','nodejs','terraform']
image: ['ansible', 'java', 'nodejs', 'terraform']

steps:
- uses: actions/checkout@v1
Expand All @@ -63,8 +62,8 @@ jobs:
with:
name: base-image
path: /tmp
-
name: Load Base Image

- name: Load Base Image
run: |
docker load --input /tmp/base-image.tar
Expand All @@ -77,19 +76,41 @@ jobs:
for entry in ${currentDir}/docker/${image}/*.json;
do
buildImage "${currentDir}/docker/${image}" "$entry"
imageName=$(cat "$entry" | grep 'repository' | cut -d'"' -f4)
fileName=$(echo "$imageName" | cut -d'/' -f2 | cut -d'-' -f1)
mkdir -p /tmp/docker-images/
docker save -o /tmp/docker-images/$fileName-image.tar $imageName
done
- name: Upload Image(s)
uses: actions/upload-artifact@v2
with:
name: docker-images-${{matrix.image}}
path: /tmp/docker-images/

deploy:
needs: [build]
name: Deploy ${{ matrix.image }} image(s)
runs-on: ubuntu-latest
strategy:
matrix:
image: ['ansible', 'java', 'nodejs', 'terraform']
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v1

- name: Set up packer
- name: Download Images
uses: actions/download-artifact@v2
with:
name: docker-images-${{matrix.image}}
path: /tmp/docker-images/

- name: Load Images
run: |
wget https://releases.hashicorp.com/packer/1.8.0/packer_1.8.0_linux_amd64.zip
unzip packer_1.8.0_linux_amd64.zip
for entry in /tmp/docker-images/*.tar;
do
docker load --input $entry
done
- name: Login to Docker Hub
uses: docker/login-action@v1
Expand All @@ -98,17 +119,35 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
email: 'oss@holisticon.de'

- name: Build and Deploy Release Images
- name: Push Release Images
run: |
export PATH=$PATH:$(pwd)
./.bin/build.sh
./.bin/deploy.sh
source ./.bin/_bash.inc
export image=${{matrix.image}}
for entry in ${currentDir}/docker/${image}/*.json;
do
imageName=$(cat "$entry" | grep 'repository' | cut -d'"' -f4)
fileName=$(echo "$imageName" | cut -d'/' -f2 | cut -d'-' -f1)
docker tag ${imageName}:${IMAGE_TAG} ${imageName}:${MAJOR_DOCKER_TAG}
docker tag ${imageName}:${IMAGE_TAG} ${imageName}:${MINOR_DOCKER_TAG}
docker tag ${imageName}:${IMAGE_TAG} ${imageName}:latest
docker push ${imageName}:latest
docker push ${imageName}:${MAJOR_DOCKER_TAG}
docker push ${imageName}:${MINOR_DOCKER_TAG}
done
if: github.ref == 'refs/heads/master'

- name: Build and Deploy Snaphot Images
- name: Push Snaphot Images
run: |
export TIMESTAMP=$(date +%s)
export PATH=$PATH:$(pwd)
./.bin/build.sh $TIMESTAMP
./.bin/deploy.sh $TIMESTAMP
source ./.bin/_bash.inc
export image=${{matrix.image}}
for entry in ${currentDir}/docker/${image}/*.json;
do
timeStamp=$(date +%s)
imageName=$(cat "$entry" | grep 'repository' | cut -d'"' -f4)
fileName=$(echo "$imageName" | cut -d'/' -f2 | cut -d'-' -f1)
docker tag ${imageName}:${IMAGE_TAG} ${imageName}:${timeStamp}
docker push ${imageName}:${timeStamp}
done
if: github.ref == 'refs/heads/develop'

0 comments on commit db394bc

Please sign in to comment.