From fec50ae91576fb93c75b8492ee8ff26b766e65d0 Mon Sep 17 00:00:00 2001 From: Laura Date: Sat, 6 Jan 2024 18:19:41 +0100 Subject: [PATCH] Add new and update existing github actions --- .github/workflows/dependabot-validator.yml | 20 +++++++++++ .github/workflows/docker-image.yml | 41 ++++++++++++++-------- .github/workflows/dockerfile-validator.yml | 20 +++++++++++ .github/workflows/linting.yml | 4 +-- .github/workflows/tests.yml | 2 +- 5 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/dependabot-validator.yml create mode 100644 .github/workflows/dockerfile-validator.yml diff --git a/.github/workflows/dependabot-validator.yml b/.github/workflows/dependabot-validator.yml new file mode 100644 index 0000000..8ded5e8 --- /dev/null +++ b/.github/workflows/dependabot-validator.yml @@ -0,0 +1,20 @@ +name: dependabot validator + +on: + pull_request: + paths: + - '.github/dependabot.yml' + - '.github/workflows/dependabot-validator.yml' +jobs: + test: + name: verify-dependabot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: marocchino/validate-dependabot@v2 + id: validate + - uses: marocchino/sticky-pull-request-comment@v2 + if: always() + with: + header: validate-dependabot + message: ${{ steps.validate.outputs.markdown }} diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4022755..25443a0 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -10,20 +10,31 @@ jobs: name: build-docker-image runs-on: ubuntu-latest steps: - - name: checkout code - uses: actions/checkout@v3 - - name: install buildx + - name: Prepare + run: | + tag=$(echo "${{ github.ref }}" | cut -d "/" -f3) + echo "NEW_TAG=${tag}" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 id: buildx - uses: crazy-max/ghaction-docker-buildx@v1 + + - name: Login to Docker Hub + uses: docker/login-action@v3 with: - version: latest - - name: login to docker hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - - name: build the image - run: | - NEW_TAG=$(echo "${{ github.ref }}" | cut -d "/" -f3) - echo "Docker image tag: ${NEW_TAG}" - docker buildx build --push \ - --tag torilabs/ipsec-prometheus-exporter:latest \ - --tag torilabs/ipsec-prometheus-exporter:${NEW_TAG} \ - --platform linux/amd64,linux/arm/v7,linux/arm64 . + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: torilabs/ipsec-prometheus-exporter:latest,torilabs/ipsec-prometheus-exporter:${{ env.NEW_TAG }} diff --git a/.github/workflows/dockerfile-validator.yml b/.github/workflows/dockerfile-validator.yml new file mode 100644 index 0000000..221360a --- /dev/null +++ b/.github/workflows/dockerfile-validator.yml @@ -0,0 +1,20 @@ +name: dockerfile validator + +on: + pull_request: + paths: + - 'Dockerfile' + - '.github/workflows/dockerfile-validator.yml' + +jobs: + test: + name: verify-dockerfile + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + - name: Verify Dockerfile + uses: ghe-actions/dockerfile-validator@v1 + with: + dockerfile: 'Dockerfile' + lint: 'dockerlint' diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index c3ff227..98739ca 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -4,10 +4,10 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: [ '*' ] jobs: - linting: + test: name: linting runs-on: ubuntu-latest steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe3d51d..f6b8110 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: [ '*' ] jobs: test: