-
-
Notifications
You must be signed in to change notification settings - Fork 13
34 lines (30 loc) · 1.09 KB
/
main.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
name: Build and Deploy containers
on:
# Always test on pull request
pull_request: []
# Deploy on merge to main
push:
branches:
- master
jobs:
deploy-test-containers:
runs-on: ubuntu-latest
name: Build Container
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker build -t ghcr.io/urlstechie/urlchecker .
DOCKER_TAG=$(docker run ghcr.io/urlstechie/urlchecker --version)
printf "Docker Tag is ${DOCKER_TAG}\n"
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
- name: Login and Deploy Test Container
if: (github.event_name != 'pull_request')
run: |
docker images
printf "Docker Tag is ${DOCKER_TAG}\n"
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
docker tag ghcr.io/urlstechie/urlchecker:latest "ghcr.io/urlstechie/urlchecker:${DOCKER_TAG}"
docker push ghcr.io/urlstechie/urlchecker:latest
docker push "ghcr.io/urlstechie/urlchecker:${DOCKER_TAG}"