diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100755 index 0000000000..7a62ba87e2 --- /dev/null +++ b/.github/workflows/main.yml @@ -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/scp-action@v0.1.7 + 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 diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000000..fa0188ae57 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/action.yml b/action.yml new file mode 100755 index 0000000000..782c83020b --- /dev/null +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000000..3fee027dff --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh -l + +echo "Hello $1" +time=$(date) +echo "time=$time" >> $GITHUB_OUTPUT