Skip to content

Merge pull request #152 from puppetlabs/cdpe-7069/download-trivy-db-s… #144

Merge pull request #152 from puppetlabs/cdpe-7069/download-trivy-db-s…

Merge pull request #152 from puppetlabs/cdpe-7069/download-trivy-db-s… #144

name: Build-Test-Push
on:
workflow_dispatch:
inputs:
tag:
description: Optional tag to create in addition to the `latest` and `<timestamp>-<sha>` image tags.
required: false
push:
branches:
- main
jobs:
Build-Test-Push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build rootless image
run: ./build-rootless.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1)
- name: Build standard image
run: ./build.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1)
- name: Run tests
run: cd tests; ./run_tests.sh
- name: Tag Docker images
run: |
docker tag puppet-dev-tools:latest-rootless ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)-rootless
docker tag puppet-dev-tools:latest ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)
- name: Additional Tag
if: inputs.tag
run: |
docker tag puppet-dev-tools:latest-rootless ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}-rootless
docker tag puppet-dev-tools:latest ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}
- name: List Docker images
run: docker images --filter "reference=puppet-dev-tools*" --filter "reference=*/puppet-dev-tools*"
- name: Show Docker image labels
run: |
docker inspect --format='{{json .Config.Labels}}' ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)
- name: Login to Docker Hub
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_LOGIN_USERNAME }} --password-stdin
- name: Push Docker images
run: |
docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)-rootless
docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)
- name: Push Additional Tag
if: inputs.tag
run: |
docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}-rootless
docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}