From 1c1605b3496dfc6b5e6bc981b59af5357aa99a3f Mon Sep 17 00:00:00 2001 From: ASAKURA Kazuki <32762324+Arthur1@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:13:47 +0900 Subject: [PATCH] refinement github actions workflows --- .github/workflows/on-push-version-tag.yml | 10 +++++++ .github/workflows/on-push.yml | 8 +++++ .github/workflows/wf-build.yml | 36 +++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .github/workflows/on-push-version-tag.yml create mode 100644 .github/workflows/on-push.yml create mode 100644 .github/workflows/wf-build.yml diff --git a/.github/workflows/on-push-version-tag.yml b/.github/workflows/on-push-version-tag.yml new file mode 100644 index 0000000..6eb1009 --- /dev/null +++ b/.github/workflows/on-push-version-tag.yml @@ -0,0 +1,10 @@ +name: On push version tag +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" +jobs: + build-push: + uses: ./.github/workflows/wf-build.yml + with: + needs-push: true diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml new file mode 100644 index 0000000..e755a39 --- /dev/null +++ b/.github/workflows/on-push.yml @@ -0,0 +1,8 @@ +name: On push +on: + push: + tags-ignore: + - "[0-9]+.[0-9]+.[0-9]+" +jobs: + build: + uses: ./.github/workflows/wf-build.yml diff --git a/.github/workflows/wf-build.yml b/.github/workflows/wf-build.yml new file mode 100644 index 0000000..b2d22fa --- /dev/null +++ b/.github/workflows/wf-build.yml @@ -0,0 +1,36 @@ +name: Build +on: + workflow_call: + inputs: + needs-push: + type: boolean + default: false +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + 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 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Get tag + id: get_tag + run: echo "::set-output name=tag::${GITHUB_REF##*/}" + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: | + mackerel/mackerel-agent:latest + mackerel/mackerel-agent:${{ steps.get_tag.outputs.tag }}