github action: improve env and dependencies and logic

This commit is contained in:
Oliver Gorwits
2021-08-22 20:04:27 +01:00
parent ef2624c108
commit 76796e7531

View File

@@ -24,7 +24,7 @@ jobs:
name: Test and CPAN Upload name: Test and CPAN Upload
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: 'netdisco/netdisco:2.047002-do' image: 'netdisco/netdisco:latest-do'
options: '--user root --entrypoint /bin/ash' options: '--user root --entrypoint /bin/ash'
volumes: volumes:
- '/home/runner/work:/github/workspace' - '/home/runner/work:/github/workspace'
@@ -32,11 +32,8 @@ jobs:
run: run:
working-directory: /github/workspace/netdisco/netdisco working-directory: /github/workspace/netdisco/netdisco
steps: steps:
- name: Get the Tag and Branch - name: Get the Tag or Branch
id: get_refs run: echo "GH_REF_SHORT=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
run: |
echo ::set-output name=RELEASE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=RELEASE_BRANCH::${GITHUB_REF#refs/heads/}
- name: Install packages - name: Install packages
run: apk add openssh xz tmux bash curl sudo gcc make musl-dev perl-dev unzip run: apk add openssh xz tmux bash curl sudo gcc make musl-dev perl-dev unzip
@@ -63,22 +60,22 @@ jobs:
continue-on-error: true continue-on-error: true
- name: IRC test failure notification - name: IRC test failure notification
uses: Gottox/irc-message-action@v2
if: (steps.build_and_run_tests.outcome == 'failure') && (github.event_name != 'workflow_dispatch') if: (steps.build_and_run_tests.outcome == 'failure') && (github.event_name != 'workflow_dispatch')
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions
message: |- message: |-
🤖 ${{ github.actor }} pushed to ${{ steps.get_refs.outputs.RELEASE_BRANCH }}: https://github.com/${{ github.repository }}/commit/${{ github.sha }} 🤖 ${{ github.actor }} pushed to ${{ env.GH_REF_SHORT }}: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
😭 TESTS have FAILED! 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 😭 TESTS have FAILED! 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: IRC test success notification - name: IRC test success notification
uses: Gottox/irc-message-action@v2
if: (steps.build_and_run_tests.outcome == 'success') && github.event.inputs.success_irc_squawk if: (steps.build_and_run_tests.outcome == 'success') && github.event.inputs.success_irc_squawk
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions
message: |- message: |-
🤖 ${{ github.actor }} pushed to ${{ steps.get_refs.outputs.RELEASE_BRANCH }}: https://github.com/${{ github.repository }}/commit/${{ github.sha }} (tests PASSED 🎉) 🤖 ${{ github.actor }} pushed to ${{ env.GH_REF_SHORT }}: https://github.com/${{ github.repository }}/commit/${{ github.sha }} (tests PASSED 🎉)
- name: Make release - name: Make release
if: steps.build_and_run_tests.outcome == 'success' if: steps.build_and_run_tests.outcome == 'success'
@@ -88,9 +85,6 @@ jobs:
sudo -u netdisco /home/netdisco/bin/localenv ./Build distmeta sudo -u netdisco /home/netdisco/bin/localenv ./Build distmeta
sudo -u netdisco /home/netdisco/bin/localenv ./Build dist sudo -u netdisco /home/netdisco/bin/localenv ./Build dist
- name: Check CPAN Release
run: bash -c 'RELEASENAME=(App-Netdisco-*.tar.gz) && ! curl -LI --fail https://cpan.metacpan.org/authors/id/O/OL/OLIVER/${RELEASENAME}'
- name: Upload to CPAN - name: Upload to CPAN
id: upload_to_cpan id: upload_to_cpan
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
@@ -98,26 +92,27 @@ jobs:
PAUSE_USERNAME: ${{ secrets.PAUSE_USERNAME }} PAUSE_USERNAME: ${{ secrets.PAUSE_USERNAME }}
PAUSE_PASSWORD: ${{ secrets.PAUSE_PASSWORD }} PAUSE_PASSWORD: ${{ secrets.PAUSE_PASSWORD }}
run: | run: |
bash -c 'RELEASENAME=(App-Netdisco-*.tar.gz) && ! curl -LI --fail https://cpan.metacpan.org/authors/id/O/OL/OLIVER/${RELEASENAME}'
sudo -u netdisco /home/netdisco/bin/localenv cpan-upload -u '${{ env.PAUSE_USERNAME }}' -p '${{ env.PAUSE_PASSWORD }}' App-Netdisco-*.tar.gz sudo -u netdisco /home/netdisco/bin/localenv cpan-upload -u '${{ env.PAUSE_USERNAME }}' -p '${{ env.PAUSE_PASSWORD }}' App-Netdisco-*.tar.gz
continue-on-error: true continue-on-error: true
- name: IRC upload failure notification - name: IRC upload failure notification
uses: Gottox/irc-message-action@v2
if: steps.upload_to_cpan.outcome == 'failure' if: steps.upload_to_cpan.outcome == 'failure'
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions
message: |- message: |-
🤖 Failed to upload Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN! 😭 🤖 Failed to upload Netdisco release ${{ env.GH_REF_SHORT }} to CPAN! 😭
👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: IRC upload success notification - name: IRC upload success notification
uses: Gottox/irc-message-action@v2
if: steps.upload_to_cpan.outcome == 'success' if: steps.upload_to_cpan.outcome == 'success'
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions
message: |- message: |-
🤖 Uploaded Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN 🎉 🤖 Uploaded Netdisco release ${{ env.GH_REF_SHORT }} to CPAN 🎉
- name: Setup tmate session - name: Setup tmate session
uses: mxschmitt/action-tmate@v3 uses: mxschmitt/action-tmate@v3
@@ -125,14 +120,10 @@ jobs:
with: with:
sudo: true sudo: true
- name: Fix job exit status - name: Preserve status from tests
if: always() && (steps.build_and_run_tests.outcome == 'failure') if: always() && (steps.build_and_run_tests.outcome == 'failure')
run: exit 1 run: exit 1
- name: Fix job exit status
if: always() && github.event.inputs.debug_docker_enabled
run: exit 0
build_docker_images: build_docker_images:
name: Build Docker Images name: Build Docker Images
needs: test_netdisco needs: test_netdisco
@@ -239,8 +230,8 @@ jobs:
run: docker logout run: docker logout
- name: IRC DH upload failure notification - name: IRC DH upload failure notification
uses: Gottox/irc-message-action@v2
if: steps.upload_docker_hub.outcome == 'failure' if: steps.upload_docker_hub.outcome == 'failure'
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions
@@ -248,8 +239,8 @@ jobs:
🤖 Failed to publish containers to Docker Hub (release ${{ env.TAG }}) 😭 🤖 Failed to publish containers to Docker Hub (release ${{ env.TAG }}) 😭
👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: IRC DH upload success notification - name: IRC DH upload success notification
uses: Gottox/irc-message-action@v2
if: steps.upload_docker_hub.outcome == 'success' if: steps.upload_docker_hub.outcome == 'success'
uses: Gottox/irc-message-action@v2
with: with:
channel: '#netdisco' channel: '#netdisco'
nickname: github-actions nickname: github-actions