-
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.
- Loading branch information
0 parents
commit 03d1369
Showing
4 changed files
with
128 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,20 @@ | ||
name: Action | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: ./ | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
name: gh-runner | ||
uses: ./.github/workflows/docker-build.yaml | ||
with: | ||
REGISTRY: ghcr.io | ||
ORGANISATION_NAME: philwelz |
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,64 @@ | ||
name: Build & Publish to Registry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
### Values from CICD Workflow ### | ||
REGISTRY: | ||
required: true | ||
type: string | ||
description: 'The Environemnt which should be used.' | ||
ORGANISATION_NAME: | ||
type: string | ||
required: true | ||
description: 'The Subscription ID which should be used.' | ||
|
||
env: | ||
IMAGE: '${{ inputs.REGISTRY }}/${{ inputs.ORGANISATION_NAME }}/gh-runner' | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ inputs.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: | | ||
${{ env.IMAGE }} | ||
tags: | | ||
type=raw,latest | ||
type=sha,prefix=,suffix=,short=true | ||
- name: Build and push the fred version of the WebApp | ||
uses: docker/[email protected] | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
platforms: linux/amd64 | ||
push: true | ||
context: ./gh-runner | ||
file: ./gh-runner/Dockerfile | ||
tags: ${{ steps.meta.outputs.tags }} | ||
|
||
- name: Display image tag in summary | ||
run: | | ||
echo "### Build & release! :rocket:" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "Released image:" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "- ${{steps.meta.outputs.tags}}" >> $GITHUB_STEP_SUMMARY |
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,15 @@ | ||
FROM ghcr.io/actions/actions-runner:2.311.0 | ||
|
||
USER root | ||
|
||
# install curl and jq | ||
RUN apt-get update && apt-get install -y curl jq && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY entrypoint.sh ./entrypoint.sh | ||
RUN chmod +x ./entrypoint.sh | ||
|
||
USER runner | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] |
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,29 @@ | ||
#!/bin/sh -l | ||
|
||
# Retrieve a short lived runner registration token using the PAT | ||
REGISTRATION_TOKEN="$(curl -X POST -fsSL \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
-H "Authorization: Bearer $GITHUB_PAT" \ | ||
-H 'X-GitHub-Api-Version: 2022-11-28' \ | ||
"$REGISTRATION_TOKEN_API_URL" \ | ||
| jq -r '.token')" | ||
|
||
# Configure | ||
if [[ "${ephemeralRunner}" == "true" ]]; then | ||
|
||
./config.sh \ | ||
--url $REPO_URL \ | ||
--token $REGISTRATION_TOKEN \ | ||
--unattended \ | ||
--ephemeral \ | ||
&& ./run.sh | ||
|
||
else | ||
|
||
./config.sh \ | ||
--url $REPO_URL \ | ||
--token $REGISTRATION_TOKEN \ | ||
--unattended \ | ||
&& ./run.sh | ||
|
||
fi |