-
Notifications
You must be signed in to change notification settings - Fork 0
33 lines (26 loc) · 1.21 KB
/
Copy pathdocker.yml
File metadata and controls
33 lines (26 loc) · 1.21 KB
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
name: Docker Image CI
on:
# pull_request:
# branches: [ "main" ]
# types: ["closed"]
push:
branches: [ "main" ]
jobs:
build_and_push_docker_image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker image tag
id: vars
run: echo "IMAGE_TAG=$(date +%s)" >> $GITHUB_ENV
- name: Build the Docker image
run: docker build . --file Dockerfile --tag wiibleyde-portfolio:${{ env.IMAGE_TAG }} --tag wiibleyde-portfolio:latest
- name: Push the Docker image
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: docker tag wiibleyde-portfolio:${{ env.IMAGE_TAG }} ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g'):${{ env.IMAGE_TAG }}
- run: docker tag wiibleyde-portfolio:latest ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g'):latest
- run: docker push ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g'):${{ env.IMAGE_TAG }}
- run: docker push ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g'):latest