Skip to content

Commit

Permalink
Merge pull request #5 from ardikabs/explore/github-actions
Browse files Browse the repository at this point in the history
chore: explore GitHub Actions
  • Loading branch information
ardikabs authored Sep 3, 2023
2 parents 944ccb1 + 12ed63b commit a98f0de
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Container

on:
# manual trigger workflow
workflow_dispatch:
inputs:
context:
description: The container image context located, which relative to `dockerfiles` directory.
required: true
type: string
dockerfile:
description: Dockerfile path relative to the context. Default to '${context}/Dockerfile'.
type: string
default: Dockerfile
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
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Log in to the GitHub Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: dockerfiles/${{ inputs.context }}
file: dockerfiles/${{ inputs.context }}/${{ inputs.dockerfile }}
push: true
tags: ghcr.io/${{ github.repository }}/${{ inputs.image_name }}:${{ inputs.image_tag }}
platforms: linux/amd64,linux/arm64
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
64 changes: 64 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a98f0de

Please sign in to comment.