From d2d01f025fd056dd555006f64574b86b5142a767 Mon Sep 17 00:00:00 2001 From: David <45599674+martialonline@users.noreply.github.com> Date: Tue, 19 May 2020 13:55:08 +0100 Subject: [PATCH] Migrate to GitHub Actions (#100) * Add actions workflow * Update secrets for Docker push --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ build/ci/Jenkinsfile | 7 ----- 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 build/ci/Jenkinsfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ef951f58 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: Continuous Integration + +on: + push: + branches: + - '**' + pull_request: + branches: + - master + create: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +env: + DOCKER_BUILDKIT: 1 + +jobs: + + build: + name: Build Artifacts + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Unit Tests + run: make test + - name: Build Prometheus-Exporter + run: make nginx-prometheus-exporter + - name: Build Image + uses: docker/build-push-action@v1 + with: + repository: nginx/nginx-prometheus-exporter + dockerfile: build/Dockerfile + path: '.' + tag_with_sha: true + push: false + + publish: + name: Publish Artifacts + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'create' && contains(github.ref, 'refs/tags/') + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Retrieve Tag + id: get_version + run: echo ::set-output name=GIT_TAG::$(echo ${GITHUB_REF/refs\/tags\//} | tr -d v) + - name: Push Image + uses: docker/build-push-action@v1 + with: + repository: nginx/nginx-prometheus-exporter + dockerfile: build/Dockerfile + path: '.' + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + registry: ${{ secrets.DOCKER_REGISTRY }} + tag_with_ref: false + tags: latest, ${{ steps.get_version.outputs.GIT_TAG }} + push: true \ No newline at end of file diff --git a/build/ci/Jenkinsfile b/build/ci/Jenkinsfile deleted file mode 100644 index 4afafa73..00000000 --- a/build/ci/Jenkinsfile +++ /dev/null @@ -1,7 +0,0 @@ -node { - git( - url: "${libsLocation}", - credentialsId: "${githubCreds}" - ) - load 'nginx-prometheus-exporter/Jenkinsfile' -} \ No newline at end of file