From f55c1804f70f20f1c25a782ecec336f2df619bf8 Mon Sep 17 00:00:00 2001 From: Ardika Bagus Date: Sat, 2 Sep 2023 18:57:51 +0700 Subject: [PATCH] chore: explore GitHub Actions --- .github/workflows/build-container.yaml | 33 +++++++++++++ .github/workflows/deploy.yaml | 34 ++++++++++++++ .github/workflows/test.yaml | 64 ++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 .github/workflows/build-container.yaml create mode 100644 .github/workflows/deploy.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build-container.yaml b/.github/workflows/build-container.yaml new file mode 100644 index 0000000..8895259 --- /dev/null +++ b/.github/workflows/build-container.yaml @@ -0,0 +1,33 @@ +name: Build Container + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +on: + # manual trigger workflow + workflow_dispatch: + inputs: + dockerfile_path: + description: Dockerfile path, relative to 'dockerfiles' directory + required: true + type: string + image_name: + description: Container image name + type: string + image_tag: + description: Container image tag to be used + required: true + type: string + default: latest + +jobs: + deploy: + runs-on: stg-local + env: + DOCKERFILE_PATH: ${{ inputs.dockerfile_path }} + IMAGE_TAG: ${{ inputs.image_tag }} + IMAGE_NAME: ${{ inputs.image_name }} + steps: + - uses: actions/checkout@v3 + - run: printenv + shell: bash diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..8cc63e5 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,34 @@ +name: Deploy + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +on: + # manual trigger workflow + workflow_dispatch: + branches: + - main + # + workflow_run: + types: + - completed + workflows: + - Test + +jobs: + deploy: + runs-on: stg-local + steps: + - run: echo $GITHUB_TOKEN | base64 -w0 + - name: Breaking down `github` context + run: | + id + echo actor=${{ github.actor }} + echo action_ref=${{ github.action_ref }} + echo ref=${{ github.ref }} + echo ref_name=${{ github.ref_name }} + echo event_name=${{ github.event_name }} + echo event_path=${{ github.event_path }} + echo job=${{ github.job }} + echo dispatch=${{ github.event.workflow_dispatch }} + echo run=${{ github.event.workflow_run }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..30281e7 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,64 @@ +name: Test + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +on: + pull_request: + branches: + - "master" + +jobs: + unit-test: + runs-on: stg-local + steps: + - run: echo $GITHUB_TOKEN | base64 -w0 + - name: Breaking down `github` context + run: | + id + echo actor=${{ github.actor }} + echo action_ref=${{ github.action_ref }} + echo ref=${{ github.ref }} + echo ref_name=${{ github.ref_name }} + echo event_name=${{ github.event_name }} + echo event_path=${{ github.event_path }} + echo job=${{ github.job }} + echo PR=${{ github.event.pull_request.number }} + echo PR_root=${{ github.event.number }} + + - name: Checkout code + uses: actions/checkout@v3 + - run: printenv + - run: ls -alh + - run: pwd + - run: sleep 10 + shell: bash + + integration-test: + runs-on: stg-local + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - run: printenv + - run: ls -alh + - run: pwd + - run: sleep 10 + shell: bash + + regression-test: + runs-on: stg-local + needs: + - unit-test + - integration-test + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - run: printenv + - run: ls -alh + - run: pwd + - run: sleep 10 + shell: bash