From 9afecf681d1d4c3733bd31485bb22e58750aa896 Mon Sep 17 00:00:00 2001 From: Benita Diop <45861503+BenitaDiop@users.noreply.github.com> Date: Fri, 28 Feb 2020 23:15:24 -0800 Subject: [PATCH 1/2] dockerpush.yml --- .github/workflows/dockerpush.yml | 93 ++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/dockerpush.yml diff --git a/.github/workflows/dockerpush.yml b/.github/workflows/dockerpush.yml new file mode 100644 index 0000000..bc1a916 --- /dev/null +++ b/.github/workflows/dockerpush.yml @@ -0,0 +1,93 @@ +name: Docker + +on: + push: + # Publish `master` as Docker `latest` image. + branches: + - master + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + +env: + # TODO: Change variable to your image's name. + IMAGE_NAME: image + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + if [ -f docker-compose.test.yml ]; then + docker-compose --file docker-compose.test.yml build + docker-compose --file docker-compose.test.yml run sut + else + docker build . --file Dockerfile + fi + + # Push image to GitHub Package Registry. + # See also https://docs.docker.com/docker-hub/builds/ + push: + # Ensure test job passes before pushing image. + needs: test + + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build . --file Dockerfile --tag image + + - name: Log into registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + + - name: Push image + run: | + IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag image $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION + +- name: Setup Python environment + uses: actions/setup-python@v1.1.1 + with: + # Version range or exact version of a Python version to use, using semvers version range syntax. + python-version: # optional, default is 3.x + # The target architecture (x86, x64) of the Python interpreter. + architecture: # optional, default is x64 + +- name: Upgrade to Python 3 +uses: cclauss/Upgrade-to-Python3@0.1.0 + + +- name: Setup Python environment + uses: actions/setup-python@v1.1.1 + with: + # Version range or exact version of a Python version to use, using semvers version range syntax. + python-version: # optional, default is 3.x + # The target architecture (x86, x64) of the Python interpreter. + architecture: # optional, default is x64 From 29e1d319ecbfb85ada43bf015b3c300b0adb2d74 Mon Sep 17 00:00:00 2001 From: Benita Diop <45861503+BenitaDiop@users.noreply.github.com> Date: Mon, 9 Mar 2020 01:12:00 -0700 Subject: [PATCH 2/2] Delete dockerpush.yml --- .github/workflows/dockerpush.yml | 93 -------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 .github/workflows/dockerpush.yml diff --git a/.github/workflows/dockerpush.yml b/.github/workflows/dockerpush.yml deleted file mode 100644 index bc1a916..0000000 --- a/.github/workflows/dockerpush.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Docker - -on: - push: - # Publish `master` as Docker `latest` image. - branches: - - master - - # Publish `v1.2.3` tags as releases. - tags: - - v* - - # Run tests for any PRs. - pull_request: - -env: - # TODO: Change variable to your image's name. - IMAGE_NAME: image - -jobs: - # Run tests. - # See also https://docs.docker.com/docker-hub/builds/automated-testing/ - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Run tests - run: | - if [ -f docker-compose.test.yml ]; then - docker-compose --file docker-compose.test.yml build - docker-compose --file docker-compose.test.yml run sut - else - docker build . --file Dockerfile - fi - - # Push image to GitHub Package Registry. - # See also https://docs.docker.com/docker-hub/builds/ - push: - # Ensure test job passes before pushing image. - needs: test - - runs-on: ubuntu-latest - if: github.event_name == 'push' - - steps: - - uses: actions/checkout@v2 - - - name: Build image - run: docker build . --file Dockerfile --tag image - - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest - - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - - docker tag image $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - -- name: Setup Python environment - uses: actions/setup-python@v1.1.1 - with: - # Version range or exact version of a Python version to use, using semvers version range syntax. - python-version: # optional, default is 3.x - # The target architecture (x86, x64) of the Python interpreter. - architecture: # optional, default is x64 - -- name: Upgrade to Python 3 -uses: cclauss/Upgrade-to-Python3@0.1.0 - - -- name: Setup Python environment - uses: actions/setup-python@v1.1.1 - with: - # Version range or exact version of a Python version to use, using semvers version range syntax. - python-version: # optional, default is 3.x - # The target architecture (x86, x64) of the Python interpreter. - architecture: # optional, default is x64