ci/cd: Dockerfile #317
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
name: Build and Publish app | |
on: | |
push: | |
branches: dev | |
jobs: | |
build: | |
name: Build app | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_LOGIN }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Build and push to Docker Hub | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./Dockerfile | |
build-args: NOTION_SECRET=${{ secrets.NOTION_TOKEN }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha, mode=max | |
tags: ${{ secrets.DOCKERHUB_ORG }}/landing-page:latest | |
open-shift: | |
name: Deploy to OC | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install oc | |
uses: redhat-actions/[email protected] | |
- name: Login to OpenShift | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} | |
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | |
insecure_skip_tls_verify: true | |
namespace: ${{ secrets.OPENSHIFT_NAMESPACE }} | |
- name: Create project | |
run: oc new-project ${{ secrets.OPENSHIFT_NAMESPACE }} || oc project ${{ secrets.OPENSHIFT_NAMESPACE }} | |
- name: Pull from Docker registry | |
run: docker pull ${{ secrets.DOCKERHUB_ORG }}/landing-page:latest | |
- name: Login to Rahti registry | |
run: sudo docker login -p ${{ secrets.OPENSHIFT_TOKEN }} -u unused docker-registry.rahti.csc.fi | |
- name: Push to Rahti registry | |
run: sudo docker tag ${{ secrets.DOCKERHUB_ORG }}/landing-page:latest docker-registry.rahti.csc.fi/${{ secrets.OPENSHIFT_NAMESPACE }}/landing-page:latest && sudo docker push docker-registry.rahti.csc.fi/${{ secrets.OPENSHIFT_NAMESPACE }}/landing-page | |
- name: Delete app | |
id: destroy-app | |
run: oc delete all -l app=landing-page-dev | |
- name: Create app with route | |
run: | | |
oc new-app landing-page --namespace=${{ secrets.OPENSHIFT_NAMESPACE }} --name=landing-page-dev | |
oc expose svc/landing-page-dev --name=elixir |