diff --git a/.github/workflows/jenkins-agent-python-pr.yaml b/.github/workflows/jenkins-agent-python-pr.yaml new file mode 100644 index 000000000..053ac83b1 --- /dev/null +++ b/.github/workflows/jenkins-agent-python-pr.yaml @@ -0,0 +1,31 @@ +name: jenkins-agent-python-pr +on: + pull_request: + paths: + - jenkins-slaves/jenkins-slave-python/** +jobs: + build: + env: + context: jenkins-slaves/jenkins-slave-python + image_name: jenkins-agent-python + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Check and verify version.json + id: check_version + run: | + echo -n ::set-output name=IMAGE_TAGS:: + echo $(jq -r '.version' ${context}/version.json) + - name: Build image + uses: docker/build-push-action@v1 + with: + path: ${{ env.context }} + push: false + repository: ${{ env.image_name }} + tags: ${{ steps.check_version.outputs.IMAGE_TAGS }} + - name: Test image + run: | + echo "Running: docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version" + docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} python --version + echo "Running: docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version" + docker run ${image_name}:${{ steps.check_version.outputs.IMAGE_TAGS }} pip --version diff --git a/.github/workflows/jenkins-agent-python-publish.yaml b/.github/workflows/jenkins-agent-python-publish.yaml new file mode 100644 index 000000000..2ee1e4118 --- /dev/null +++ b/.github/workflows/jenkins-agent-python-publish.yaml @@ -0,0 +1,39 @@ +name: jenkins-agent-python-publish +on: + push: + branches: + - master + tags: + - '*' + paths: + - jenkins-slaves/jenkins-slave-python/version.json +jobs: + build: + env: + context: jenkins-slaves/jenkins-slave-python + image_name: jenkins-agent-python + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Get image tags + id: image_tags + run: | + echo -n ::set-output name=IMAGE_TAGS:: + VERSION=$(jq -r '.version' ${context}/version.json) + TAGS=('latest') + if [ "${VERSION}" ] && [ "${VERSION}" != "latest" ]; then + TAGS+=("${VERSION}") + fi + if [[ "${GITHUB_REF}" =~ refs/tags/(.*) ]]; then + TAGS+=("git-${BASH_REMATCH[1]}") + fi + ( IFS=$','; echo "${TAGS[*]}" ) + - name: Build and publish image to Quay + uses: docker/build-push-action@v1 + with: + path: ${{ env.context }} + registry: ${{ secrets.REGISTRY_URI }} + repository: ${{ secrets.REGISTRY_REPOSITORY }}/${{ env.image_name }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}" diff --git a/jenkins-slaves/jenkins-slave-python/Dockerfile b/jenkins-slaves/jenkins-slave-python/Dockerfile index ad2e50aee..d78f7a65f 100644 --- a/jenkins-slaves/jenkins-slave-python/Dockerfile +++ b/jenkins-slaves/jenkins-slave-python/Dockerfile @@ -23,6 +23,7 @@ RUN INSTALL_PKGS=" \ yum -y clean all --enablerepo='*' && \ source scl_source enable rh-python36 && \ scl enable rh-python36 bash && \ + python3 -m pip install --upgrade pip && \ python3 -m pip install twine ADD scl_enable /usr/share/container-scripts/ diff --git a/jenkins-slaves/jenkins-slave-python/version.json b/jenkins-slaves/jenkins-slave-python/version.json new file mode 100644 index 000000000..bf1cf4649 --- /dev/null +++ b/jenkins-slaves/jenkins-slave-python/version.json @@ -0,0 +1 @@ +{"version":"v1.0"}