forked from NCAR/ccpp-scm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_and_push_docker_latest.yml
More file actions
38 lines (30 loc) · 1021 Bytes
/
build_and_push_docker_latest.yml
File metadata and controls
38 lines (30 loc) · 1021 Bytes
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
name: build_test_and_push_docker
on:
push:
branches:
# Only build containers when pushing to main
- "main"
env:
LATEST_TAG: dtcenter/ccpp-scm:latest
jobs:
docker:
if: github.repository == 'NCAR/ccpp-scm'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if secrets are defined
run: |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ]; then echo "Username is MISSING"; else echo "Username is SET"; fi
if [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then echo "Token is MISSING"; else echo "Token is SET"; fi
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
run: |
docker build -t ${{ env.LATEST_TAG}} docker/
- name: Push Docker image
run: |
docker push ${{ env.LATEST_TAG }}