Skip to content

Commit

Permalink
Merge branch 'OCD-4459-test' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
andlar committed Mar 4, 2024
2 parents 2fd94b7 + c598d97 commit 700e2fa
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: deploy files
on: [push]
jobs:

deploy_website_container:
runs-on: ubuntu-latest
name: Deploy the website container to an environment it can be picked up
steps:
- name: checkout
uses: actions/checkout@v4

- name: branch name
run: echo running on branch ${GITHUB_REF##*/}

- name: docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
chpl-website/app
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=raw,latest
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: build the image
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
outputs: type=docker,dest=/tmp/app.tar

- name: save the file
uses: actions/upload-artifact@v4
with:
name: app
path: /tmp/app.tar

- name: restore the file
uses: actions/download-artifact@v4
with:
name: app
path: distfiles

- name: copy file to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
source: distfiles/*
target: ${{ secrets.TARGET }}

- name: load the image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
echo ${{ secrets.PASSWORD }} | sudo -S docker load --input distfiles/app.tar
echo ${{ secrets.PASSWORD }} | sudo -S docker image ls -a
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Container image that runs your code
FROM alpine:3.10

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# action.yml
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -l

echo "Hello $1"
time=$(date)
echo "time=$time" >> $GITHUB_OUTPUT

0 comments on commit 700e2fa

Please sign in to comment.