-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ardikabs/explore/github-actions
chore: explore GitHub Actions
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Build Container | ||
|
||
run-name: Build Container - ${{ inputs.name }} | ||
|
||
on: | ||
# manual trigger workflow | ||
workflow_dispatch: | ||
inputs: | ||
name: | ||
description: The container image name, this is also being used as context to be 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 | ||
tag: | ||
description: Container image tag to be used | ||
required: true | ||
type: string | ||
default: latest | ||
|
||
jobs: | ||
build: | ||
runs-on: stg-local | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Log in to the GitHub Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/setup-qemu-action@v1 | ||
# Reference: https://github.com/docker/setup-buildx-action/issues/105 | ||
- name: Set up Docker Context for Buildx | ||
run: docker context create builders | ||
- uses: docker/setup-buildx-action@v2 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
endpoint: builders | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: dockerfiles/${{ inputs.name }} | ||
file: dockerfiles/${{ inputs.name }}/${{ inputs.dockerfile }} | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}/${{ inputs.name }}:${{ inputs.tag }} | ||
platforms: linux/amd64,linux/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
branches: | ||
- master | ||
- main | ||
|
||
workflow_run: | ||
types: | ||
- completed | ||
workflows: | ||
- Test | ||
|
||
jobs: | ||
deploy: | ||
runs-on: stg-local | ||
environment: | ||
name: Development | ||
steps: | ||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- "master" | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: stg-local | ||
steps: | ||
- name: Sneak peek `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: 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: 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: sleep 10 | ||
shell: bash |