.github/workflows/publish.yml
name: Build and push
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-deploy
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Get build args
id: bargs
run: |
echo "::set-output name=shortsha::$(git rev-parse --short ${GITHUB_SHA})"
echo "::set-output name=buildurl::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
echo "::set-output name=date::$(date +'%d/%m/%y %H:%M')"
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .deploy/
secrets: master_key=${{ secrets.RAILS_MASTER_KEY }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
site_version=${{ steps.meta.outputs.version }}
site_build_hash=${{ steps.bargs.outputs.shortsha }}
site_build_url=${{ steps.bargs.outputs.buildurl }}
site_build_time=${{ steps.bargs.outputs.date }}
- name: Redeploy container on Jelastic
run: |
curl -X POST -d envName=webapps \
-d session=${{ secrets.JELASTIC_SESSION }} \
-d tag=${{ steps.meta.outputs.version }} \
-d nodeId=${{ secrets.JELASTIC_NODE_ID }} \
-d useExistingVolumes=false \
https://app.jpc.infomaniak.com/1.0/environment/control/rest/redeploycontainerbyid