diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index aace356d..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Build Docker Images -on: - workflow_dispatch: - inputs: - debug_enabled: - description: 'Run debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' - required: false - default: false -# success_irc_squawk: -# description: 'Squawk to IRC on success' -# required: false -# default: false - push: - tags: - - '2.[0-9][0-9][0-9][0-9][0-9][0-9]' -jobs: - build_docker_images: - name: Build Docker Images - runs-on: ubuntu-latest - defaults: - run: - working-directory: /home/runner/work/netdisco/netdisco-docker - steps: - - name: Check out latest code - uses: actions/checkout@v1 - with: - repository: 'netdisco/netdisco-docker' - ref: 'master' - - - name: Get the Tag - id: get_refs - run: | - echo "TAG=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - echo "IMAGE_ROOT=netdisco:${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - - name: Build netdisco-postgresql - run: | - cd netdisco-postgresql - docker build -t ${IMAGE_ROOT}-postgresql \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg TAG=${TAG} \ - --build-arg COMMITTISH=${TAG} . - docker tag ${IMAGE_ROOT}-postgresql netdisco/${IMAGE_ROOT}-postgresql - - - name: Build netdisco-base - run: | - cd netdisco-base - docker build -t ${IMAGE_ROOT}-base \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg TAG=${TAG} \ - --build-arg COMMITTISH=${TAG} . - docker tag ${IMAGE_ROOT}-base netdisco/${IMAGE_ROOT}-base - - - name: Build netdisco-backend - run: | - cd netdisco-backend - docker build -t ${IMAGE_ROOT}-backend \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg TAG=${TAG} \ - --build-arg COMMITTISH=${TAG} . - docker tag ${IMAGE_ROOT}-backend netdisco/${IMAGE_ROOT}-backend - - - name: Build netdisco-web - run: | - cd netdisco-web - docker build -t ${IMAGE_ROOT}-web \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg TAG=${TAG} \ - --build-arg COMMITTISH=${TAG} . - docker tag ${IMAGE_ROOT}-web netdisco/${IMAGE_ROOT}-web - - - name: Build netdisco-do - run: | - cd netdisco-do - docker build -t ${IMAGE_ROOT}-do \ - --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ - --build-arg TAG=${TAG} \ - --build-arg COMMITTISH=${TAG} . - docker tag ${IMAGE_ROOT}-do netdisco/${IMAGE_ROOT}-do - - - name: Tag all images latest - run: | - for image in postgresql backend web do; do - docker tag ${IMAGE_ROOT}-$image netdisco/netdisco:latest-$image - done - - - name: Upload all images - if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - for image in postgresql backend web do; do - docker push netdisco/${IMAGE_ROOT}-$image - docker push netdisco/netdisco:latest-$image - done - -# - name: IRC upload failure notification -# uses: Gottox/irc-message-action@v2 -# if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') -# with: -# channel: '#netdisco' -# nickname: github-actions -# message: |- -# 🤖 Failed to upload Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN! 😭 -# 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} -# - name: IRC upload success notification -# uses: Gottox/irc-message-action@v2 -# if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') -# with: -# channel: '#netdisco' -# nickname: github-actions -# message: |- -# 🤖 Uploaded Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN 🎉 - - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: always() && github.event.inputs.debug_enabled && (github.event_name == 'workflow_dispatch') - with: - sudo: true - diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index 9d74749d..2c1fadca 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -1,9 +1,13 @@ -name: Test Netdisco +name: Test and Publish Netdisco on: workflow_dispatch: inputs: - debug_enabled: - description: 'Run debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + debug_test_enabled: + description: 'Run debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false + debug_docker_enabled: + description: 'Run debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false success_irc_squawk: @@ -60,7 +64,7 @@ jobs: - name: IRC test failure notification uses: Gottox/irc-message-action@v2 - if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/heads/') && (steps.build_and_run_tests.outcome == 'failure') + if: (! github.event.inputs.debug_test_enabled) && startsWith(github.ref, 'refs/heads/') && (steps.build_and_run_tests.outcome == 'failure') with: channel: '#netdisco' nickname: github-actions @@ -78,7 +82,7 @@ jobs: - name: Upload dist to CPAN id: upload_to_cpan - if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.build_and_run_tests.outcome == 'success') + if: (! github.event.inputs.debug_test_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.build_and_run_tests.outcome == 'success') env: PAUSE_USERNAME: ${{ secrets.PAUSE_USERNAME }} PAUSE_PASSWORD: ${{ secrets.PAUSE_PASSWORD }} @@ -89,7 +93,7 @@ jobs: - name: IRC upload failure notification uses: Gottox/irc-message-action@v2 - if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_to_cpan.outcome == 'failure') + if: (! github.event.inputs.debug_test_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_to_cpan.outcome == 'failure') with: channel: '#netdisco' nickname: github-actions @@ -98,7 +102,7 @@ jobs: 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - name: IRC upload success notification uses: Gottox/irc-message-action@v2 - if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_to_cpan.outcome == 'success') + if: (! github.event.inputs.debug_test_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_to_cpan.outcome == 'success') with: channel: '#netdisco' nickname: github-actions @@ -107,7 +111,129 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - if: always() && github.event.inputs.debug_enabled && (github.event_name == 'workflow_dispatch') + if: always() && github.event.inputs.debug_test_enabled && (github.event_name == 'workflow_dispatch') + with: + sudo: true + + build_docker_images: + name: Build Docker Images + needs: test_netdisco + runs-on: ubuntu-latest + defaults: + run: + working-directory: /home/runner/work/netdisco/netdisco-docker + steps: + - name: Check out latest code + uses: actions/checkout@v1 + with: + repository: 'netdisco/netdisco-docker' + ref: 'master' + + - name: Get the Tag + id: get_refs + run: | + echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "IMAGE_ROOT=netdisco:${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build netdisco-postgresql + run: | + cd netdisco-postgresql + docker build -t ${IMAGE_ROOT}-postgresql \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg TAG=${TAG} \ + --build-arg COMMITTISH=${TAG} . + docker tag ${IMAGE_ROOT}-postgresql netdisco/${IMAGE_ROOT}-postgresql + + - name: Build netdisco-base + run: | + cd netdisco-base + docker build -t ${IMAGE_ROOT}-base \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg TAG=${TAG} \ + --build-arg COMMITTISH=${TAG} . + docker tag ${IMAGE_ROOT}-base netdisco/${IMAGE_ROOT}-base + + - name: Build netdisco-backend + run: | + cd netdisco-backend + docker build -t ${IMAGE_ROOT}-backend \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg TAG=${TAG} \ + --build-arg COMMITTISH=${TAG} . + docker tag ${IMAGE_ROOT}-backend netdisco/${IMAGE_ROOT}-backend + + - name: Build netdisco-web + run: | + cd netdisco-web + docker build -t ${IMAGE_ROOT}-web \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg TAG=${TAG} \ + --build-arg COMMITTISH=${TAG} . + docker tag ${IMAGE_ROOT}-web netdisco/${IMAGE_ROOT}-web + + - name: Build netdisco-do + run: | + cd netdisco-do + docker build -t ${IMAGE_ROOT}-do \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg TAG=${TAG} \ + --build-arg COMMITTISH=${TAG} . + docker tag ${IMAGE_ROOT}-do netdisco/${IMAGE_ROOT}-do + + - name: Tag all images latest + run: | + for image in postgresql backend web do; do + docker tag ${IMAGE_ROOT}-$image netdisco/netdisco:latest-$image + done + + - name: Upload to Docker Hub + id: upload_docker_hub + if: (! github.event.inputs.debug_docker_enabled) && startsWith(github.ref, 'refs/tags/') + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + for image in postgresql backend web do; do + docker push netdisco/${IMAGE_ROOT}-$image + docker push netdisco/netdisco:latest-$image + done + docker logout + continue-on-error: true + + - name: Upload to GitHub Packages + id: upload_github_packages + if: (! github.event.inputs.debug_docker_enabled) && startsWith(github.ref, 'refs/tags/') + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + for image in postgresql backend web do; do + docker push netdisco/${IMAGE_ROOT}-$image + docker push netdisco/netdisco:latest-$image + done + docker logout + continue-on-error: true + + - name: IRC DH upload failure notification + uses: Gottox/irc-message-action@v2 + if: (! github.event.inputs.debug_docker_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_docker_hub.outcome == 'failure') + with: + channel: '#netdisco' + nickname: github-actions + message: |- + 🤖 Failed to publish containers (release ${{ steps.get_refs.outputs.RELEASE_TAG }}) 😭 + 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + - name: IRC DH upload success notification + uses: Gottox/irc-message-action@v2 + if: (! github.event.inputs.debug_docker_enabled) && startsWith(github.ref, 'refs/tags/') && (steps.upload_docker_hub.outcome == 'success') + with: + channel: '#netdisco' + nickname: github-actions + message: |- + 🤖 Published containers (release: ${{ steps.get_refs.outputs.RELEASE_TAG }}) 🎉 + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: always() && github.event.inputs.debug_docker_enabled && (github.event_name == 'workflow_dispatch') with: sudo: true