generated from bwbioinfo/docker-cwl-template
-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (38 loc) · 1.33 KB
/
build-and-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Build and Push Docker Image
on:
workflow_run:
workflows: [Build and Test Docker Image]
types: [completed]
branches:
- main
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: get-name
run: |
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV
echo "REPO_OWNER=$(echo ${{ github.repository_owner}} | tr '[:upper:]' '[:lower:]' )" >> $GITHUB_ENV
- name: print-name
run: |
echo "${{ env.REPO_NAME }}"
echo "${{ env.REPO_OWNER }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
run: |
docker build \
-t ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }} \
-t ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest . -f docker/Dockerfile
- name: Push Docker image
run: |
docker push ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }} &&
docker push ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest