From 860e28c5fd135bf0c3f9e29b9cf077a287f160ff Mon Sep 17 00:00:00 2001 From: nalbam Date: Fri, 6 Oct 2023 16:28:49 +0000 Subject: [PATCH] github action --- .github/workflows/push.yml | 113 ++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 46 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bc66f6c..b749307 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,8 +1,9 @@ -name: Build-Push +name: build on: push: branches: + - main - master jobs: @@ -11,24 +12,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: - fetch-depth: 1 - - - name: Bump Version - uses: opspresso/action-builder@master - with: - args: --version + fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v1 with: - node-version: "12.x" + node-version: "16.x" - - name: Run Build - run: | - # npm run lint - npm run build + - name: Bump Version + id: bump + uses: opspresso/action-builder@master + with: + args: --version - name: Release to GitHub uses: opspresso/action-builder@master @@ -36,42 +33,66 @@ jobs: args: --release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ steps.bump.outputs.version }} - # - name: Trigger for GitOps - # uses: opspresso/action-builder@master - # with: - # args: --dispatch - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # GITOPS_REPO: "nalbam/argocd-env-demo" - # EVENT_TYPE: "build" - # TARGET_ID: "deepracer-timer" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - # - name: Build & Push to Docker Hub - # uses: opspresso/action-builder@master - # with: - # args: --docker - # env: - # # USERNAME: ${{ secrets.DOCKER_USERNAME }} - # PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - # LATEST: "true" + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 - - name: Build & Push to GitHub Package - uses: opspresso/action-builder@master + - name: Login to DockerHub + uses: docker/login-action@v2 with: - args: --docker - env: - # USERNAME: ${{ secrets.DOCKER_USERNAME }} - PASSWORD: ${{ secrets.GITHUB_PERSONAL_TOKEN }} - REGISTRY: "docker.pkg.github.com" - LATEST: "true" + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build & Push to AWS ECR - uses: opspresso/action-builder@master + - name: Login to Github Container Registry + uses: docker/login-action@v2 with: - args: --ecr - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: "ap-northeast-2" - LATEST: "true" + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_BRUCE }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_BRUCE }} + aws-region: ap-northeast-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + nalbam/${{ github.event.repository.name }} + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} + ${{ steps.login-ecr.outputs.registry }}/nalbam/${{ github.event.repository.name }} + tags: | + type=semver,pattern={{raw}},value=${{ steps.bump.outputs.version }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # - name: Trigger for GitOps + # uses: opspresso/action-builder@master + # with: + # args: --dispatch + # env: + # GITHUB_TOKEN: ${{ secrets.GHP_TOKEN }} + # GITOPS_REPO: "opspresso/argocd-env-demo" + # PROJECT: ${{ github.event.repository.name }} + # VERSION: ${{ steps.bump.outputs.version }}