Skip to content

Commit

Permalink
ci: test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
killmenot committed Apr 16, 2024
1 parent 37490fc commit d58e8b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Items that don't need to be in a Docker image.
# Anything not used by the build system should go here.
.*
Dockerfile
README.md

# Artifacts that will be built during image creation.
# This should contain all files created during `npm run build`.
node_modules
43 changes: 28 additions & 15 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,40 @@ concurrency:
group: cd-${{ github.ref }}
cancel-in-progress: false

# env:
# REPO_URL: ghcr.io
# REPO_PROJECT: swiftdrivecorp
# REPO_CONFIG: infra-deploy

# ghcr.io/swiftdrivecorp/frontend-admin-staging:123456
# ghcr.io/swiftdrivecorp/frontend-admin-prodution:123456

jobs:
test:
name: "Extract environment name"
build-and-push:
name: "Build and push docker image"
runs-on: ubuntu-latest
outputs:
swf-environment: ${{ steps.extract.outputs.environment }}
environment: ${{ steps.extract.outputs.environment }}
steps:
- id: extract
run: echo "swf-environment=$([[ '${{ github.event.action }}' == 'prereleased' ]] && echo 'staging' || echo 'production')" >> $GITHUB_OUTPUT
- id: test
run: 'echo "Extracted environment name: $EXTRACTED"'
name: Extract environment
run: echo "environment=$([[ '${{ github.event.action }}' == 'prereleased' ]] && echo 'staging' || echo 'production')" >> $GITHUB_OUTPUT

- name: Print environment
run: 'echo "Extracted environment: $EXTRACTED"'
env:
EXTRACTED: ${{ steps.extract.outputs.swf-environment }}
EXTRACTED: ${{ steps.extract.outputs.environment }}

- name: Checkout repository
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker image
run: |
docker build -t ghcr.io/killmenot/github-test-${{ steps.extract.outputs.environment }}:${{ github.event.release.tag_name }} -f Dockerfile .
- name: Push docker image to GitHub Container Registry
run: |
docker push ghcr.io/killmenot/github-test-${{ steps.extract.outputs.environment }}:${{ github.event.release.tag_name }}
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:1.25.4-alpine

COPY /static /usr/share/nginx/html
RUN chown nginx.nginx /usr/share/nginx/html/ -R

EXPOSE 80
2 changes: 2 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Hello World</h1>
h1>

0 comments on commit d58e8b0

Please sign in to comment.