-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
52fbd30
commit b3c34a6
Showing
17 changed files
with
3,058 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
name: 'Docker Build' | ||
description: 'Builds docker image' | ||
inputs: | ||
push: | ||
required: false | ||
description: "Build and push image to registry (cannot be used together with load)" | ||
default: "false" | ||
|
||
outputs: | ||
tags: | ||
description: "The Docker tags for the image" | ||
value: ${{ steps.meta.outputs.tags }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Validate inputs | ||
shell: bash | ||
run: | | ||
if [[ "${{ inputs.push }}" == "true" && "${{ github.ref }}" == "refs/heads/master" ]]; then | ||
echo "Cannot push to registry from master branch unless we migrate our master build job to GHA." | ||
exit 1 | ||
fi | ||
# Setup docker to build for multiple architectures | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
version: latest | ||
buildkitd-flags: --debug | ||
|
||
# Login to a registry to push the image | ||
- name: Login to Container Registry | ||
# Only login if we are pushing the image | ||
if: ${{ inputs.push == 'true' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: 'ghcr.io' | ||
|
||
# Determine the tags for the image | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
# Hard coding our dockerhub imnage name | ||
images: mozilla/test-github-features | ||
tags: | | ||
type=schedule | ||
type=ref,event=tag | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
# set latest tag for default branch | ||
# Disabled for now as we do not use this action for | ||
# The production build | ||
# type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Build Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
pull: true | ||
push: ${{ inputs.push }} | ||
load: ${{ inputs.push == 'false' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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,47 @@ | ||
name: 'Docker Run Action' | ||
description: 'Run a command in a new container' | ||
inputs: | ||
image: | ||
description: "The Docker image to run" | ||
required: true | ||
options: | ||
description: 'Options' | ||
required: false | ||
run: | ||
description: 'Run command in container' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Run Docker Container | ||
shell: bash | ||
run: | | ||
cat <<EOF > exec.sh | ||
#!/bin/bash | ||
whoami | ||
${{ inputs.run }} | ||
EOF | ||
cat <<EOF > root.sh | ||
#!/bin/bash | ||
whoami | ||
su -s /bin/bash -c './exec.sh' olympia | ||
EOF | ||
# Make both files executable | ||
chmod +x exec.sh | ||
chmod +x root.sh | ||
# Debug info | ||
echo "############" | ||
cat root.sh | ||
echo "############" | ||
echo "############" | ||
cat exec.sh | ||
echo "############" | ||
# Execute inside docker container | ||
cat root.sh | docker run ${{ inputs.options }} \ | ||
-i --rm -u 0 \ | ||
-v $(pwd):/app \ | ||
${{ inputs.image }} bash |
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,14 @@ | ||
name: Build | ||
|
||
on: | ||
create: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci_build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
uses: ./.github/actions/build | ||
|
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
name: Merge | ||
on: | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
merge_build: | ||
if: ${{ github.event_name == 'merge_group' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/build | ||
- name: Update txt | ||
shell: bash | ||
run: | | ||
RANDOM_NUMBER=$((RANDOM % 1000000)) | ||
echo "Hello World $RANDOM_NUMBER" > hello.txt | ||
git add hello.txt | ||
git commit -m "Update hello.txt" | ||
git push |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
name: Push | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy_staging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Deploy to staging | ||
run: | | ||
echo "Deploying to staging" | ||
# Your deployment script here | ||
deploy_production: | ||
runs-on: ubuntu-latest | ||
needs: deploy_staging | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Deploy to production | ||
run: | | ||
echo "Deploying to production" | ||
# Your deployment script here | ||
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,27 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/build | ||
- name: Test | ||
uses: ./.github/actions/run | ||
with: | ||
run: | | ||
echo "Testing" | ||
npm run test | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/build | ||
- name: Lint | ||
uses: ./.github/actions/run | ||
with: | ||
run: | | ||
echo "Linting" | ||
npm run lint | ||
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,27 @@ | ||
FROM node:18 as base | ||
|
||
WORKDIR /app | ||
COPY --chown=node package*.json /app/ | ||
|
||
RUN /bin/bash <<EOF | ||
npm install | ||
EOF | ||
|
||
FROM base as builder | ||
|
||
COPY --from=base /app/node_modules /app/node_modules | ||
COPY src package.json tsconfig.json /app/ | ||
|
||
RUN npm run build | ||
|
||
FROM base as final | ||
|
||
COPY --from=builder /app/dist /app/dist | ||
COPY --from=base /app/package.json /app/package.json | ||
|
||
RUN npm i --omit=dev --no-save | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "run", "start"] | ||
|
Oops, something went wrong.