trying to fix error output #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- release.* | |
env: | |
GIT_SHA: ${{ github.sha }} | |
REG_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} | |
REG_PATH: ${{ secrets.DOCKER_REGISTRY_PATH }} | |
REG_USER: ${{ secrets.DOCKER_USERNAME }} | |
REG_PASS: ${{ secrets.DOCKER_PASSWORD }} | |
#REG_HOST: ghcr.io | |
#REG_PATH: ${{ github.repository }} | |
#REG_USER: ${{ github.actor }} | |
#REG_PASS: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
needs-ghcr: | |
runs-on: ubuntu-latest | |
outputs: | |
also_ghcr: ${{ steps.check.outputs.also_ghcr }} | |
steps: | |
- id: check | |
env: | |
MY_KEY: ${{ secrets.ALSO_GHCR }} | |
if: "${{ env.MY_KEY != '' }}" | |
run: echo "also_ghcr=true" >> $GITHUB_OUTPUT | |
modified-folders: | |
runs-on: ubuntu-latest | |
env: | |
OUTFILE: folders.txt | |
outputs: | |
need_updates: ${{ steps.check_need_updates.outputs.need_updates }} | |
steps: | |
- uses: actions/checkout@v1 | |
- name: create file list | |
run: python .github/modified-images.py | |
- name: Calculate number of folders | |
id: check_need_updates | |
run: | | |
[ -s "$OUTFILE" ] && echo "need_updates=1">>$GITHUB_OUTPUT || echo "need_updates=0">>$GITHUB_OUTPUT | |
- name: Upload folder list | |
uses: actions/upload-artifact@v1 | |
with: | |
name: folder-list | |
path: folders.txt | |
modified-folders-ghcr: | |
runs-on: ubuntu-latest | |
needs: [needs-ghcr, modified-folders] | |
env: | |
OUTFILE: folders1.txt | |
REG_HOST: ghcr.io | |
REG_PATH: ${{ github.repository }} | |
REG_USER: ${{ github.actor }} | |
REG_PASS: ${{ secrets.GITHUB_TOKEN }} | |
if: needs.needs-ghcr.outputs.also_ghcr == 'true' | |
#outputs: | |
# need_updates: ${{ steps.check_need_updates.outputs.need_updates }} | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/download-artifact@v1 | |
with: | |
name: folder-list | |
- name: create file list | |
run: python .github/modified-images.py | |
#- name: Calculate number of folders | |
# id: check_need_updates | |
# run: | | |
# [ -s "$OUTFILE" ] && echo "::set-output name=need_updates::1" || echo "::set-output name=need_updates::0" | |
- name: merge folder lists | |
run: | | |
cat folder-list/folders.txt folders1.txt > folders.txt | |
- name: upload folder list | |
uses: actions/upload-artifact@v1 | |
with: | |
name: folder-list | |
path: folders.txt | |
build: | |
runs-on: ubuntu-latest | |
needs: [ "modified-folders", "modified-folders-ghcr", "needs-ghcr"] | |
#if: needs.modified-folders.outputs.need_updates==1 | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/download-artifact@v1 | |
with: | |
name: folder-list | |
- name: Login to GitHub Docker Registry | |
if: needs.needs-ghcr.outputs.also_ghcr == 'true' | |
uses: docker/login-action@v1 | |
with: | |
registry: "ghcr.io" | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log in to registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REG_HOST }} | |
username: ${{ env.REG_USER }} | |
password: ${{ env.REG_PASS }} | |
- name: Build the images | |
run: | | |
echo '====================================================' | |
echo "Will build these directories:" | |
cat folder-list/folders.txt | |
echo '====================================================' | |
while read f TAG VER; do | |
echo Folder $f, will be tagged as $TAG:$VER | |
if docker build $f/ --tag $TAG:$VER --tag $TAG:latest ; then | |
docker history $TAG:$VER | |
docker push $TAG:$VER | |
docker push $TAG:latest | |
else | |
echo "BUILD FAILED" | |
echo $f $TAG $VER >> errors.txt | |
fi | |
echo '====================================================' | |
done < folder-list/folders.txt | |
- run: | | |
[ -e "errors.txt" ] && (echo "ERRORS!" && cat errors.txt) || true |